Skip to content

Instantly share code, notes, and snippets.

@berak
Last active February 19, 2017 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berak/b23262a9cb08a9d0a6d3 to your computer and use it in GitHub Desktop.
Save berak/b23262a9cb08a9d0a6d3 to your computer and use it in GitHub Desktop.
#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