Ask Your Question

Revision history [back]

i tried your image with the code below and result is OK

could you post your code that did not find the face...

#include "opencv2/objdetect.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"

#include <iostream>

using namespace std;
using namespace cv;


int main( int argc, const char** argv )
{

    Mat image;
    CascadeClassifier face_cascade;
    //-- 1. Load the cascades
    if( !face_cascade.load( "E:/git/opencv/data/haarcascades/haarcascade_frontalface_alt.xml" ) ){ printf("--(!)Error loading face cascade\n"); return -1; };

    image = imread("e:/test/15004038028938638.jpg");

    std::vector<Rect> faces;
    Mat image_gray;

    cvtColor(image, image_gray, COLOR_BGR2GRAY);
    equalizeHist(image_gray, image_gray);

    //-- Detect faces
    face_cascade.detectMultiScale(image_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));

    for (size_t i = 0; i < faces.size(); i++)
    {
        rectangle(image, faces[i], Scalar(255, 0, 255), 3);
    }
    //-- Show what you got
    imshow("result", image);
    waitKey(0);

    return 0;
}