我一直在测试两种不同的高斯混合物(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.
先谢谢。
答案 0 :(得分:0)
我在我的项目中实现的用于背景扣除的代码是我自己的。我没有使用这些内置函数,因为其中很多都非常慢。
我做的是: -
考虑一个像素,如果它的值在大约15-20帧左右没有变化,则该像素对应于背景像素。我们将该像素保存在图像中。我们将这个过程重复10000帧以覆盖整个图像。(使用我们得到的背景的近似图像没有前景对象)
为了删除我所做的背景,我将每个像素的R,G,B值与对应于背景图像的像素进行比较。(取R,G的平均差值,像素的B值)如果此值小于阈值(应该由您设置,可能使用滑块),那么该像素对应于背景,然后我做的是我拍了另一张图像并制作了相应的像素黑色,否则该像素对应于前景对象并将其RGB值复制到我们的新图像中。该过程在所有像素上迭代。 (以这种方式你可以从前景中删除背景)
要检测阴影,您可以使用滑块根据需要更改阈值。
答案 1 :(得分:0)
基于OpenCV的替代实现了许多最近的阴影检测算法,提供了更高质量的阴影检测:
http://arma.sourceforge.net/shadows/
还有一个关联的journal article,描述了所有已实现的算法及其各种权衡(例如质量与速度)。