Understanding cascade xml file for smile like emotion detection

asked 2016-11-23 15:58:05 -0600

Hello,

I am trying use OpenCV to detect smile from face on real time video on iOS project. I have some sample and trying to make it work. I have seen a cascade smile.xml file being added in the project. When I tested the app, it couldn't detect smile face coming from camera video. I doubt, how this cascade.xml file created? Is there any standard cascade xml files (to use CvHaarClassifierCascade) to detect emotions like smile, sad etc.?

I am looking at this sample here, https://github.com/lukagabric/iOS-OpenCV

  • (void)viewDidLoad { NSString path = [[NSBundle mainBundle] pathForResource:@"smile" ofType:@"xml"]; _cascade = (CvHaarClassifierCascade)cvLoad([path cStringUsingEncoding:NSASCIIStringEncoding], NULL, NULL, NULL); _storage = cvCreateMemStorage(0);

    [super viewDidLoad];

}

  • (void)didCaptureIplImage:(IplImage *)iplImage { IplImage *imgRGB = cvCreateImage(cvGetSize(iplImage), IPL_DEPTH_8U, 3); cvCvtColor(iplImage, imgRGB, CV_BGR2RGB);

    IplImage *imgSmall = cvCreateImage(cvSize(imgRGB->width/2, imgRGB->height/2), IPL_DEPTH_8U, 3); cvPyrDown(imgRGB, imgSmall, CV_GAUSSIAN_5x5);

    CvSeq *smiles = cvHaarDetectObjects(imgSmall, _cascade, _storage, 1.1f, 3, CV_HAAR_DO_CANNY_PRUNING);

    for (int i = 0; i < smiles->total; i++)

    {

CvRect cvrect = (CvRect)cvGetSeqElem(smiles, 0);

    Mat matImgSmall = Mat(imgSmall);

    rectangle(matImgSmall, cvrect, Scalar(255, 0, 0));
}

if (smiles->total > 0)
{
    [self showSmileWithImage:imgSmall];
}
else
{
    cvReleaseImage(&imgSmall);
}

[self didFinishProcessingImage:imgRGB];

}

edit retag flag offensive close merge delete