Can I get the outline of the opencv grabcut function?

I am using opencv grabcut function for image segmentation. I looked at the sample provided in opencv using grabcut, the sample just returns as an image where all the "background" parts are colored black (0,0,0). I can just pour from each black point and get an outline. But I would like to use this function if they exist.

+3


source to share


1 answer


Grabcut returns the mask. You can use this code to get outlines:



std::vector<std::vector<cv::Point> > contours;
cv::findContours(mask, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

      

+1


source







All Articles