문제

BackgroundSubtractorMOG2 returns a contour of the foreground not a mask. How to obtain a proper mask of a foreground using OpenCV?

Thanks, Sajid

도움이 되었습니까?

해결책

the foreground mask obtained there is 8bit, your captured image is probabably 24bit(3channels). so, to apply it on your actual image , you need to convert the mask to 3 channels as well:

Mat maskrgb;
cvtColor(mask,maskrgb,CV_GRAY2BGR);
// now , apply it:
Mat draw = imagergb & (maskrgb > 0);
imshow("lalala", draw );

다른 팁

Try to use cv::fillPoly function with the input is the contour then you will have the mask. http://docs.opencv.org/doc/tutorials/core/basic_geometric_drawing/basic_geometric_drawing.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top