0
votes

I am currently trying to do face detection using OpenCV 2.4.8. I am loading haarcascade classifier : haarcascade_frontalface_alt.xml. I am using detectMultiScale function with following arguments : face_cascade.detectMultiScale(grayscaleFrame, faces, 1.1, 3,CV_HAAR_FIND_BIGGEST_OBJECT).

The problem is that it doesn't return only biggest object as it is supposed to do. I build opencv in debug mode and found out that CV_HAAR_FIND_BIGGEST_OBJECT flag is redundant in new version. Can anyone tell me other way of detecting biggest object in a frame?

1

1 Answers

4
votes

Why don't use surface as an measure how detected face big is:

std::vector<cv::Rect> faces;
face_cascade.detectMultiScale(grayscaleFrame, faces, 1.1, 3,CV_HAAR_FIND_BIGGEST_OBJECT).
cv::Rect maxRect; // 0 sized rect
for(int i=0;i<faces.size();i++) 
    if (faces[i].area() > maxRect.area())
        maxRect = faces[i];

It gives good estimation e.g. when more than one person is detected, this method in most cases gives us the face that is the closest to the camera.