Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sorry my code is not easy to understand

(void)processImage:(Mat&)grayMat; {

// Do some OpenCV stuff with the image Mat image_copy;

std::vector<cv::rect> faces;

cvtColor( grayMat, image_copy, CV_BGR2GRAY );

equalizeHist( image_copy, image_copy );

// invert image float haar_scale = 1.2;//1.15;

int haar_minNeighbors = 2;

int haar_flags = CV_HAAR_SCALE_IMAGE;//| CV_HAAR_DO_CANNY_PRUNING;

cv::Size haar_minSize = cvSize(60, 60);

face_cascade->detectMultiScale(image_copy, faces, haar_scale, haar_minNeighbors, haar_flags, haar_minSize );

for( int i = 0; i < faces.size(); i++ ) {

cv::Point center( faces[i].x + faces[i].width0.5, faces[i].y + faces[i].height0.5 );

cv::ellipse( image_copy, center, cv::Size( faces[i].width0.5, faces[i].height0.5), 0, 0, 360, cv::Scalar( 255, 0, 255 ), 4, 8, 0 );

} }