How to use dnn as a detector for facemark ?

asked 2019-11-28 10:27:13 -0500

Elis4 gravatar image


Until now, I used Haar cascade to detect faces in images and then give them to the cv::face::FacemarkLBF::fit() method to obtain the landmarks.

It worked well but I realised the cv::CascadeClassifier class was quite limitated when the face orientation is neither facing the camera nor profiling - and even when these conditions are met sometimes it fails to detect the face. I am now trying to use the cv::dnn::Net because it's more flexible.

I succeeded in findings the faces with cv::dnn::Net, using the trained model (deploy.prototxt and res10_300x300_ssd_iter_140000_fp16.caffemodel files) from the opencv repos.

However, when I then try to find the landmarks with cv::face::FacemarkLBF::fit(), the result are completely messed up : the landmarks are not following any outline of the image, the face orientation is completely wrong, ...

Event if the results of the cv::dnn::Net face detection seem right, they differ slightly from the result of the cv::CascadeClassifier class. Is the facemark API compatible with the cv::dnn::Net rectangles outputs ?

Any advice is welcome :) I'm pretty new to computer vision so I might be missing something obvious here.

PS : I would like to try other landmarks detection algorithms as well, but cannot find any pre trained models for AAM or Kazemi. If you could provide me with a link I'll be glad :)

Thanks for reading !

edit retag flag offensive close merge delete