Closed Vibhu04 closed 2 years ago
Hello @Vibhu04 , have you tried #3 yet?
Yes, I had a look at #3. The problem is that @AdrianPeniak 's repository that he had forked from yours to get the hand detection solution running doesn't exist anymore, so I couldn't follow the solution that you have provided there. I'll be really grateful if you could list the changes that should be made to your repository to make it run the hand detection solution instead.
Oh, I didn't know about that, sorry. So the detailed steps are (you should change the class + variable name for convention):
palm_detection_without_custom_layer.tflite
from here.anchors.csv
from here.models
folder.FaceDetection.cpp
, replace face_detection_short.tflite
with palm_detection_without_custom_layer.tflite
.DetectionPostProcess.hpp
:
...
#define DETECTION_SIZE 192
#define NUM_BOXES 2944
#define NUM_COORD 18
...
You are free to delete NUM_SIZE
and struct AnchorOptions
now.
DetectionPostProcess.cpp
:
#include "DetectionPostProcess.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
cv::Rect2f convertAnchorVectorToRect(const std::vector
std::vector
my::DetectionPostProcess::DetectionPostProcess() : m_anchors(generateAnchors()) {}
// The rest remains unchanged ...
7. Finally, in `demo.cpp`:
```cpp
...
int main(int argc, char* argv[]) {
my::FaceDetection irisLandmarker("./models");
cv::VideoCapture cap(0);
...
irisLandmarker.loadImageToInput(rframe);
irisLandmarker.runInference();
cv::rectangle(rframe, irisLandmarker.getFaceRoi(), cv::Scalar(0, 255, 0));
#if SHOW_FPS
Note:
DetectionPostProcess::decodeBox
, I only use the first four to get the palm position, you can modify it to get the key points).DetectionPostProcess::getHighestScoreDetection
to return multiple detections).@pntt3011 thanks a lot! Your prompt reply was very helpful.
As you had mentioned, currently the palm detection model, although jittery, returns the bounding box coordinates along with the 2D coordinates of 7 palm key points. Would you have an idea about the subsequent changes I would have to make to the repository to now incorporate the hand landmark model, in order to obtain the 3D coordinates of the 21 hand key points? Any ideas/suggestions would be very helpful.
Thanks again!
Hey @pntt3011, did you get a chance to look into how the hand landmark model can be incorporated? Any ideas/insights would be very valuable.
Hi @Vibhu04, I'm sorry for my late reply. I don't have much free time on weekdays. I will try looking into it this weekend.
Hello @Vibhu04, I find it rather simple to incorporate the hand landmark model.
hand_landmark_full.tflife
or hand_landmark_lite.tflite
from this link (move it to the models
folder of course)
(Edit 30/10/2022: Mediapipe removed the .tflite model in the master)FaceLandmark.cpp
:
#define FACE_LANDMARKS 21
...
my::FaceLandmark::FaceLandmark(std::string modelPath):
FaceDetection(modelPath),
m_landmarkModel(modelPath + std::string("/hand_landmark_lite.tflite")) // Just change the model path
{}
...
In demo.cpp
:
...
int main(int argc, char* argv[]) {
my::FaceLandmark irisLandmarker("./models"); // Change the object's class
...
irisLandmarker.loadImageToInput(rframe);
irisLandmarker.runInference();
// For visualization
// You can use cv::line to draw the connections between the landmarks instead
for (auto landmark: irisLandmarker.getAllFaceLandmarks()) {
cv::circle(rframe, landmark, 2, cv::Scalar(0, 255, 0), -1);
}
#if SHOW_FPS
...
Note:
landmark[0]
and landmark[2]
from Palm detection.my::FaceLandmark::runInference()
)my::FaceLandmark::getFaceLandmarkAt
)Thank you so much @pntt3011! Really appreciate the help.
Could someone please guide me as to what changes I should make to the files of this repository to get the hand detection solution running?