使用 OpenCV 进行高效背景扣除
我想使用 OpenCV 方法在视频文件中进行背景减除。现在我可以进行背景减法,但问题是我无法在颜色模式下获得输出。减去背景后的所有输出均采用灰度颜色模式:(。我想将颜色信息获取到前景,这是减去背景后的结果输出。
我可以使用掩蔽技术来做到这一点?? 就像我正在考虑的以下过程一样:
- 捕获输入 -
InputFrame
(RGB) - Process
InputFrame
- 减去背景,将前景存储在
TempFrame
中。 > (以灰度形式出现 :( ) - 使用
TempFrame
创建蒙版 - 将创建的蒙版应用到
InputFrame
- 获取彩色前景作为
OutFrame
我对使用 OpenCV 进行掩蔽很感兴趣,我只是 OpenCV 的初学者,请帮助我克服这个问题
。
I want to do background subtraction in a video file using OpenCV method. Right now I'm able to do background subtraction, but the problem is that I couldn't get the output in color mode. All the output after subtracting the background is coming in grayscale color mode :(. I want to get the color information to the foreground which is the resulting output after background got subtracted.
Can I do it using masking technique?? like the following procedure which I'm thinking about.
- Capture Input --
InputFrame
(RGB) - Process
InputFrame
- Subtract background, store foreground in
TempFrame
(which is coming in grayscale :( ) - Create a mask using
TempFrame
- Apply the created mask to the
InputFrame
- Get colored foreground as
OutFrame
I'm struck up with doing the masking using OpenCV. I'm just a very beginner in OpenCV. Please help me to overcome this.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://vimeo.com/27477093
代码位于此处
http://code.google.com/p/derin-deli-mavi/downloads/detail?name=denemeOpenCv23.zip& ;can=2&q=
到达彩色前景
只需使用前景蒙版复制图像
// image.copyTo(foreground,foreground);
http://vimeo.com/27477093
code is here
http://code.google.com/p/derin-deli-mavi/downloads/detail?name=denemeOpenCv23.zip&can=2&q=
to reach a colored foreground
just copy image by using foreground mask
// image.copyTo(foreground,foreground);
好吧,我不明白如果您使用背景减法,TempFrame(您的前景)怎么会是灰度的。你一定使用了一种非常特殊的算法。但假设 TempFrame 是灰度的,那么你会这样做:
这就是上面的 OpenCV 2.0 代码。数字 0.5 是一个阈值,您需要将其设置为适当的值。如果您不使用浮点图像,您可能会将其设置为 128 或类似的值。这与 OpenCV 1.1 代码中的内容相同:
Okay, I don't understand how TempFrame (your foreground) could be greyscale if you are using background subtraction. You must be using a very special algorithm. But assuming TempFrame is greyscale, then you would do this:
That is OpenCV 2.0 code above. The number 0.5 is a threshold, you'll need to set it to something appropriate. If you're not using floating-point images, you'd probably set it to 128 or something like that. This is the same thing in OpenCV 1.1 code: