I am using openCV 2.4.10 on c++ this code to count the faces in an image, but I am not getting the right result sometimes: I tried it on 50 images; only 22 images got the right result. What should I add to make it better?
int countFacesInImage(Mat frame)
{
std::vector<Rect> faces;
Mat frame_gray;
cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
equalizeHist(frame_gray, frame_gray);
// Detect faces
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));
return faces.size();
}