Skip to content

Instantly share code, notes, and snippets.

Last active February 19, 2017 21:44
What would you like to do?
#include <opencv2/opencv.hpp>
#include <opencv2/core/core_c.h> // needed for IplImage ;(
#include <dlib/image_processing.h>
#include <dlib/opencv/cv_image.h>
// 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(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment