Hand segmentation question contour extraction [closed]

asked 2017-10-07 11:59:57 -0600

Mateusz gravatar image

updated 2017-10-08 02:29:49 -0600

berak gravatar image

Hi,

I have a problem with hand segmentation. Namely, I try to segment my hand from the background, then I want to build convex hull of my hand but I can not do it because not all points are fully connected this is presented in this image: .

What I am doing: I convert BGR2YUV, then I take V channel and perform background subtraction then I want to build convex hull. However, in order to build convex hull, the contour of the hand is necessary. Do you know some good way to connect those points together to extract the hand region for building the convex hull.

while(true)
{
    Mat HSV1;
    Mat th;

    Mat YUV1;
    Mat fin_image;

    readFrame(frame);

    cvtColor(frame, YUV1, CV_BGR2YUV);

    Mat YUV[3];   

    split(YUV1,YUV);

    imshow("Y",YUV[0]);
    imshow("U",YUV[1]);
    imshow("V",YUV[2]);
    applyBackgroundMOGSubtraction(YUV[2]);
    imshow("foreground",foreground);
    findAndDrawContours(foreground);

    medianBlur(foreground, foreground, 3);
    doMorphologicalOperations(foreground);
    equalizeHist( foreground, foreground );


    imshow("foreground",foreground);        


    if(char(waitKey(30)) == 'q')
    {
        break;
    }
}

Thanks in advance for help.

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-10-11 14:35:40.121608

Comments

thanks a lot for the edit !

berak gravatar imageberak ( 2017-10-08 02:29:22 -0600 )edit

try to put all of this before finding contours:

medianBlur(foreground, foreground, 3);
doMorphologicalOperations(foreground);
equalizeHist( foreground, foreground );
berak gravatar imageberak ( 2017-10-08 02:39:04 -0600 )edit