Ask Your Question
0

Does detectmultiscale always output a square ROI when doing face detection?

asked 2014-05-30 09:41:00 -0600

updated 2014-05-30 09:53:05 -0600

berak gravatar image

Im using detectmultiscale for face detection and the output ROI is always a square, is there any settings to change this so that the output can potentially be a rectangle?

edit retag flag offensive close merge delete

Comments

it outputs the shape it was trained on, a square in the face case, a rectangle for mouth.(you can look into the xml file, it's right at the top)

but ofc, nobody said, that your application has to use exactly that. makes quite sense sometimes to crop or elongate that (i.e, out-of-the-box, it cuts off quite a lot of chin)

also, don't forget, you can train your own ..

berak gravatar imageberak ( 2014-05-30 09:49:08 -0600 )edit

Are you referring the the output ROI or the way it is marked on the screen (square vs. rectangle)?

GilLevi gravatar imageGilLevi ( 2014-05-30 10:57:07 -0600 )edit

the output roi in the 1st part, how/what to draw in the 2nd

berak gravatar imageberak ( 2014-05-30 10:59:26 -0600 )edit

Yes, I'm just not sure what he is asking about.

GilLevi gravatar imageGilLevi ( 2014-05-30 11:01:57 -0600 )edit

ahww, keep your answer, it was nice

and i'm not sure what he meant , either.

berak gravatar imageberak ( 2014-05-30 11:33:00 -0600 )edit

Thanks @berak.

By the way, I'm working on adding BinBoost (a new binary descriptor) to OpenCV. How can I find out if there is someone who is trying to do the same? I don't want to work for nothing.

GilLevi gravatar imageGilLevi ( 2014-05-30 11:50:18 -0600 )edit

oh, cool, i'll happily give it a try ;)

if you mean: "do the same thing in opencv" - does not look like there's anyone doing that.

(from looking at pull requests/issues/activity logs )

no idea , how far you are, but you could try a test balloon and make a feature request on the issues page

oh, wait found this , but no idea what to make of it

berak gravatar imageberak ( 2014-05-30 12:03:44 -0600 )edit

Actually, I've seen the thread you linked to when I googled binboost opencv.

I think I'm halfway there. I managed to extract descriptors by calling BGMDescriptorExtractor1.compute(imgK, kp, desc); But I also need to add it to the generic interface "DescriptorExtractor::create(descriptor_name);".

Also, it will be extremely helpful if someone could review my code. I'm not that proficient in C++.

GilLevi gravatar imageGilLevi ( 2014-05-30 12:41:00 -0600 )edit

Also, I need to run an evaluation on the Brown dataset to check that it's working.

GilLevi gravatar imageGilLevi ( 2014-05-30 12:41:48 -0600 )edit

again, happy to help ;)

berak gravatar imageberak ( 2014-05-30 13:08:25 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-05-30 11:48:46 -0600

You can also display the detections as ellipses and circles:

void detectAndDisplay( Mat frame ,int i)
{

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

    cvtColor( frame, frame_gray, CV_BGR2GRAY );
    equalizeHist( frame_gray, frame_gray );

    //-- Detect faces
    //face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
    face_cascade.detectMultiScale( frame_gray, faces, 1.1, 1, 0|CV_HAAR_SCALE_IMAGE, Size(20, 20) );

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

        Mat faceROI = frame_gray( faces[i] );
        std::vector<Rect> eyes;

        //-- In each face, detect eyes
        //eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) );

        for( size_t j = 0; j < eyes.size(); j++ )
        {
            Point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 );
            int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
            circle( frame, center, radius, Scalar( 255, 0, 0 ), 4, 8, 0 );
        }
    }
    //-- Show what you got
    //imshow( window_name, frame );
    char filename[512];
    sprintf(filename,"C:\\out\\image%d.jpg",i);
    imwrite(filename,frame);
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-05-30 09:41:00 -0600

Seen: 1,229 times

Last updated: May 30 '14