opencv - 如何使用opencv 2.1.0版本从前景中去除阴影

标签 opencv

我已经测试了高斯混合(MOG)的两种不同实现,用于背景减法。一种是使用opncv2.1.0,cvCreateGaussianBGModel + cvUpdateBGStatModel,另一种是使用opencv 2.4.3,BackgroundSubtractorMOG2类。

Now, 2.4.3 provide a parameter called bShadowDetect, to identify the shadow area by gray   color. But my experience with this implementation is, it does not provide the accuracy of   shadow detection. It varies according to the parameter fTau. The other issue with this   implementation is performance hit. For 640 X 480 resolution video, it is generating below 5   fps, By switching to release mode of project I get improvement upto 7 to 8 FPS.  

The another implementation of MOG is using 2.1.0. I have configured GaussianBG state   Model 's paramenters and then I am calling cvUpdateBGStatModel each time I receive a new   frame.  

For performance improvement, I have converted my frames to gray frames before I send it   for state update. My best performance till now is using opencv 2.1.0 and which is around 30   FPS for 640 X 480 resolution frames. So, currently I am preferring opencv 2.1.0 version's   MOG for background subtraction. But Here I come to face the issue of shadow removal. Here,   I want to detect only moving object. that is without shadow, and draw a rectangle to   highlight.   

Any help in this context will be grateful. 

提前致谢。

最佳答案

我在我的项目中实现的用于背景扣除的代码是我自己的。我没有使用这些内置函数,因为其中许多功能都很慢。

我所做的是:-

  • 考虑一个像素,如果它的值在大约15-20帧左右没有变化,则该像素对应于背景像素。然后将该像素保存在图像中然后我们将这个过程遍历10000帧以覆盖整个图像。(使用我们获得了没有前景对象的背景的近似图像)
  • 要删除背景,我将每个像素的R,G,B值与对应于背景图像的像素进行了比较。(取像​​素的R,G,B值之差的均方根)如果此值小于阈值(应该由您使用滑杆设置),则该像素对应于背景,然后我所做的就是我拍摄了另一张图像并将对应的像素设为黑色,否则该像素对应于前景对象,并将其RGB值复制到我们的新图像中。在所有像素上重复此过程。 (通过这种方式,您可以从前景中移除背景)
  • 要检测阴影,您可以根据需要使用滑动条更改阈值。
  • 关于opencv - 如何使用opencv 2.1.0版本从前景中去除阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13799225/

    相关文章:

    python-2.7 - Python 中 OpenCV3 中的 CreateMemStorage() 等效于什么?

    iphone opencv - 模板匹配

    python - 常规与使用 For 循环时的 Numpy 数组乘法差异

    opencv - openCV校准结果在更失真的图像上

    java - “Highgui 无法解析”、JavaCV、Eclipse

    c++ - 傅里叶逆变换手动合并实部和虚部

    opencv - 查找 HSV 值的最佳方法

    android - 导入android项目时出现问题

    python - 检测倾斜字体中单词之间的空格

    opencv - 霍夫变换 n OpenCvSharp