Ask Your Question
0

Can't detect face testing in iPhone

asked 2012-09-21 05:32:26 -0500

Thomas_N gravatar image

Dear All, I am trying face detection for iphone application. My code is as follow. But I can never detect face, faces.size() is always 0. What could be the problem?

  • (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 ); } }

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-09-21 09:03:27 -0500

Thomas_N gravatar image

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 );

} }

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-21 05:32:26 -0500

Seen: 165 times

Last updated: Sep 21 '12