Implementation of GrabCut algorithm using face detection

asked 2015-05-19 09:00:49 -0600

chrathan gravatar image

updated 2015-05-19 09:28:33 -0600

I want to create a body detection software for images using grabCut opencv c++ implementation. I have already the position of faces in the images. Therefore I want to use the information of image in order to caluclate the body bounding box using grabCut (in order to calculate the foreground). I am using the following imgproc implemenation of grabCut algorithm:

    cv::grabCut(image,    // input image
        result,   // segmentation result
        faces.at(0),// rectangle containing foreground 
        bgModel,fgModel, // models
        5,        // number of iterations
        cv::GC_INIT_WITH_RECT); // use rectangle

Where faces.at(0) the first face in the image. The result mask contain only area near the face. How can I get the whole containing area of the foreground( my body in that case)?

edit retag flag offensive close merge delete

Comments

I would suggest you to compute the rectangle of the body from the face. eg: if all the persons are standing you can suppose that the face is proportional to the body, but it seems that it is varying (wiki says)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-05-19 09:36:29 -0600 )edit

Yes sometimes the body does not take straightforward poses. Therefore it is not the best idea to calculate the boundingbox using the face. I want to calculate the boundingbox using grabcut and the face as input to grabCut algorithm.

chrathan gravatar imagechrathan ( 2015-05-19 09:43:50 -0600 )edit

"rect - It is the coordinates of a rectangle which includes the foreground object in the format (x,y,w,h)" so your body is going to be treated as background. That is why I said "you need to compute the rect of the body"

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-05-19 10:16:26 -0600 )edit

Ok I got it. However is there any implementation in which I can get the body using grabCut? I mean something like that http://docs.opencv.org/3.0-beta/doc/p...

chrathan gravatar imagechrathan ( 2015-05-20 01:54:50 -0600 )edit