opencv background subtraction get color objects

前提是你 提交于 2019-12-12 03:17:49

问题


I've used below tutorial to do background subtraction, http://docs.opencv.org/master/d1/dc5/tutorial_background_subtraction.html#gsc.tab=0

But using pMOG2->apply( frame, fgMaskMOG2 ) method return output as a binary image.

Is there any method to get only color objects after removing the background or get color image using binary image?


回答1:


One thing you can do is to use the binary image as a mask for coping the objects from the color image into another image:

// create an image like frame but initialized to zeros
cv::Mat colorForeground = cv::Mat::zeros(frame.size(), frame.type()); 
// copy color objects into the new image using mask
frame.copyTo(colorForeground, fgMaskMOG2); 

Now, in colorForeground, you can see the objects in color.



来源:https://stackoverflow.com/questions/32323190/opencv-background-subtraction-get-color-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!