scan only the lower half of a ROI?/ ROI within an ROI? [closed]

asked 2014-03-20 18:33:09 -0500

WigglesTehPro gravatar image

I am creating a facial tracking program that uses cascades that I have trained myself. In the code below the face is set as a ROI so the cascades that i have created only work in this area when a face is initially found. How would I go about scanning just the bottom half of the "faceROI"? (so that I can scan where a mouth would be).

face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CASCADE_SCALE_IMAGE, Size(30, 30) );


for ( size_t i = 0; i < faces.size(); i++ )
{
    Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
    ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2 ), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );

    Mat faceROI = frame_gray( faces[i] );



    eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
    nose_cascade.detectMultiScale( faceROI, nose, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
    mouth_cascade.detectMultiScale( faceROI, mouth, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );`
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-09-17 05:15:08.380774

Comments

Maybe it is obvious what I am saying here, but why dont you do the same you did to create the faceROI Mat? If you know that your mouth should appear on the lower half of your face, you can do:

Rect mouth_rect (faces[i].x, faces[i].y+faces[i].height/2, faces[i].width, faces[i].height/2); Mat mouthROI (faceROI(mouth_rect) mouth_cascade.detectMultiScale( mouthROI, mouth, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );

Hope that makes sense.

enrique gravatar imageenrique ( 2014-03-22 18:03:28 -0500 )edit

By the way, how many positive and negative images did you use? I am really interested in training a classifier for eyes, but I am having some issues

enrique gravatar imageenrique ( 2014-03-22 18:08:16 -0500 )edit

Thankyou i will try later when i finish work and im using around 2000 but its not as good as i want it to be you need around 6000 to be able to pick up perfectly but i dont have the time to process that many. Plus if you do decide to train yourself i found that if you use around 7000 negative images (easy to find) gives pretty good results.

WigglesTehPro gravatar imageWigglesTehPro ( 2014-03-23 03:42:29 -0500 )edit

thanks for the help it just cant get it to work though keep getting an unhandled exception error, im so close to finishing what ive started haha

WigglesTehPro gravatar imageWigglesTehPro ( 2014-03-23 14:01:29 -0500 )edit

i take that back thank-you so much! its not working yet but i nearly have it you have saved me so many hours!

WigglesTehPro gravatar imageWigglesTehPro ( 2014-03-23 14:35:22 -0500 )edit

How did you manage to set the parameters for the training? how are related the number of positive and negative images? and how are these related to the number of stages? Happy to help you ;)

enrique gravatar imageenrique ( 2014-03-27 17:50:28 -0500 )edit