Search code examples
opencvface-detectionface-recognition

Where can I find facial fiducial points haarcascade for use with opencv


I am looking for already trained haarcascades of facial fiducial points (left corner of left eye, right corner of left eye, left corner of right eye, right corner of right eye, left corner of mouth, right corner of mouth, left, center and right side of nose).
Does anyone know where can I download an already trained haarcascades to use with OpenCV's VJ function?


Solution

  • If I m not so badly mistaken, HaarCascade works with objects not with specific points. There are already classifiers for nose,eye and mouth within opencv data folder. You can detect eyes,nose and mouth with them, than you can find corners of them by using specifically well and wise crafted detection algorithms (use your imagination and mind).

    Here an example;

    CascadeClassifier cascade;  
    cascade.load("haarcascade_eye.xml");
    
    Mat im = imread("photo.jpg",0); //0 flag for grayscale
    
    vector<Rect> eyes;
    cascade.detectMultiScale(im, eyes, 1.2, 3);
    
    for (int i = 0; i < eyes.size(); i++)
    {
        Rect r = eyes[i];
        rectangle(im, Point(r.x, r.y), Point(r.x + r.width, r.y+r.height),CV_RGB(0,255,0));
    }
    
    imshow("im",im);
    

    This example finds the eyes in the loaded image. Finding mouth and nose is also similar. It finds them as rectangle and we draw these rectangles to image. I don't know if these rectangles are enough for you but if you want more specific points, like center of nose; you will need to do more processing.