1

我正在尝试找到在普通背景上跟踪不同颜色对象的最佳方法。

我已经阅读过,似乎区分颜色的最佳方法是首先将图像转换为 HSV 空间,然后基于色调的阈值。但是,由于我不仅要跟踪一个对象,而且不知道用哪个值来阈值,哪种方法最好找到这些对象的颜色?直方图方法是否有效,我忽略峰值,因为背景占据了大部分像素,然后其余的峰值代表不同的颜色?

一旦找到不同的颜色,我就可以对图像进行阈值处理,然后找到轮廓,勾勒出物体的轮廓。

有没有比我建议的方法更好的方法来跟踪 blob?

我还查看了诸如 cvBlob 之类的库,但是我在尝试安装这些库时遇到了麻烦,所以我宁愿坚持使用纯 OpenCV 实现。

作为旁注,我使用的是 C++ OpenCV 库。

4

1 回答 1

0

以下是您需要问自己的几个问题。您的问题表明您需要一个相当简单的跟踪算法。你看过哪些方法?opencv 库是入门的好地方。您是否尝试过阅读教程(即http://opencv-srf.blogspot.ro/2010/09/object-detection-using-color-seperation.html)这些将成为您构建越来越复杂的垫脚石算法。

  • 您是否需要处理遮挡(当一个对象出现在另一个对象前面时?
  • 你的背景有多么简单——它有没有改变。如果它不改变,事情会变得容易得多。
  • 物体可以自发出现在图像帧的中间还是必须从侧面出现
  • 物体在框架中移动时颜色会发生变化吗?
  • 这是 2D 还是 3D 跟踪问题?

一般来说,跟踪问题通常根据上述和许多其他问题的答案分为两部分:

  1. 物体检测(当前帧)
  2. 对象关联(来自上一帧)

在这里做出最简单的假设是伪代码实现。请注意,还有许多其他方法可以做到这一点。密集特征跟踪、稀疏特征、基于直方图、运动

#object detection (relatively easy part)
Read b = Background Image (this image needs to be read before any objects are in the scene - it can be thought of as initialization stage)
Read c = Current Image
diff = c - b > Threshold
#everywhere there is a difference indicates a part of an object
#now abstract to higher level objects based on connected components.  During occlusions you'll need to differentiate based on color, and maybe even motion if two objects are similar color
#Object association (relatively harder part)
For every object check if this object is already in your list (you'll need a distance metric here to check how similar this object is to another - based on histogram difference, feature points, motion etc...)
If in list, then add this information to the object's track
If in list, you want to consider if you need to update the object model based on the new information.  Did the object change shape/color/motion?
If not in list add it
于 2013-11-12T14:00:09.253 回答