Last active
February 19, 2017 21:44
-
-
Save berak/b23262a9cb08a9d0a6d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/opencv.hpp> | |
#include <opencv2/core/core_c.h> // needed for IplImage ;( | |
#include <dlib/image_processing.h> | |
#include <dlib/opencv/cv_image.h> | |
// IMPORTANT: | |
// do **not** use namespace cv or dlib, | |
// but prefix everything correctly !!! | |
dlib::shape_predictor sp; | |
dlib::deserialize("shape_predictor_68_face_landmarks.dat") >> sp; | |
cv::Mat img = .... // get grayscale img | |
// or use a Rect from CascadeDetection: | |
dlib::rectangle rec(0,0,img.cols,img.rows); | |
dlib::full_object_detection shape = sp(dlib::cv_image<uchar>(img), rec); | |
for (int k=0; k<shape.num_parts(); k++) { | |
cv::Point landmark(shape.part(idx[k]).x(), | |
shape.part(idx[k]).y()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment