OpenCv的图像减法问题? [英] OpenCv Issue of Image Subtraction?

查看:110
本文介绍了OpenCv的图像减法问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用功能cvAbsDiff(img1,img2,dest)减去2张图像;
它可以工作,但是有时当我将我的手放在头部或身体前时,手部不清楚,背景变成图片……背景图像(头部)覆盖了我的前景。(手)..

i am trying to subtract 2 image using the function cvAbsDiff(img1, img2, dest); it working but sometimes when i bring my hand before my head or body the hand is not clear and background comes into picture... the background image(head) overlays my foreground.(hand)..

它可以在平坦的表面上正常工作,即背景甚至像墙一样。

it works correctly on plain surfaces i.e when the background is even like a wall.

请检查我的图像...以便您可以更好地理解我的问题... !!!!

please check out my image...so that you can better understand my problem...!!!!

http://www.2shared.com/photo/hJghiq4b/bg_overlays_foreground.html

如果有任何解决方案/提示,请帮助我...。

if you have any solution/hint please help me.......

推荐答案

输入相关代码会有所帮助。也知道您实际上要实现什么。

Putting in the relevant code would help. Also knowing what you're actually trying to achieve.

您要减去哪两个图像?我已经减去了后续的图像(因此,延迟几分之一秒的时间拍摄的图像),而背景减法通常会导致移动物体的边缘,例如手的边缘,而不是物体的整个轮廓一只手。我猜您是在考虑当前框架和静态启动框架之间的差异。

Which two images are you subtracting? I've done subtracting subsequent images (so, images taken with a delay of a fraction of a second), and the background subtraction generally results in the edges of moving objects, for example the edges of a hand, and not the entire silhouette of a hand. I'm guessing you're taking the difference of the current frame and a static startup frame. It's possible that parts aren't different enough (skin+skin).

今晚我遇到了一些计算机问题,明天我将对其进行测试(请放置)

I've got some computer problems tonight, I'll test it out tomorrow (pls put up at least the steps you actually carry thorough though) and let you know.

我仍然不确定最终的目标是什么目标是,尽管我猜您要进行一些手势识别(因为您有一个称为手指的向量)。
正如Manpreet所说,您最大的问题是鲁棒性,这是由颜色相似的被摄对象造成的。

I'm still not sure what your ultimate goal is, although I'm guessing you want to do some gesture-recognition (since you have a vector called "fingers"). As Manpreet said, your biggest problem is robustness, and that is from the subjects having similar color.

我通过将脸部放在静止的状态来再现您的图像比较图片,然后移动它。如果我仅从背景入手,那么它已经强大得多,无论如何都没有显示任何覆盖。

I reproduced your image by having my face in the static comparison image, then moving it. If I started with only background, it was already much more robust and in anycase didn't display any "overlaying".

快速解决方法是,确保干净无主题的静态图像。
否则,您将需要动态比较图像,最简单的方法是将frame_n与frame_n-1比较。通常,这通常只会为您提供移动的边缘,因此,如果您想要整个轮廓,则可以:

Quick fix is, make sure to have a clean subject-free static image. Otherwise, you'll want to have dynamic comparison image, simplest would be comparing frame_n with frame_n-1. This will generally give you just the moving edges though, so if you want the entire silhouette you can either:

1)使用不同的分割算法(我建议使用这种算法)。减法速度很快,您可以使用它来确定要搜索的较小的ROI,然后使用其他算法进行更可靠的细分。)

1) Use a different segmenting algorithm (what I recommend. Background subtraction is fast and you can use it to determine a much smaller ROI in which to search, and then use a different algorithm for more robust segmentation.)

2)尝试在静态和动态比较图像之间做出折衷,例如作为过去10帧的平均值或类似的值。我不知道它的效果如何,但是实现起来很简单,值得一试:)。

2) Try to make a compromise between the static and dynamic comparison image, for example as an average of the past 10 frames or something like that. I don't know how well this works, but would be quite simple to implement, worth a try :).

另外,尝试使用CV_THRESH_OTSU而不是30作为阈值值,看看您是否更喜欢它。

Also, try with CV_THRESH_OTSU instead of 30 for your threshold value, see if you like that better.

此外,我经常注意到输出耀斑(未改变的区域从黑色切换为白色)。检查实时流,由于网络摄像头自动对焦/调整白平衡等原因,我非常确定。如果您也这样做,则关闭自动对焦等会有所帮助(顺便说一句,这不是通过openCV完成的,但取决于相机。可能要检查此内容:如何进行编程禁用摄像头的自动对焦?

Also, I noticed often the output flares (regions which haven't changed switch from black to white). Checking with the live stream, I'm quite certain it because of the webcam autofocusing/adjusting white balance etc.. If you're getting that too, turning off the autofocus etc. should help (which btw isn't done through openCV but depends on the camera. Possibly check this: How to programatically disable the auto-focus of a webcam?)

这篇关于OpenCv的图像减法问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆