图像处理 - 跟踪不同颜色的斑点

Image processing - tracking blobs of different colours

本文关键字:颜色 斑点 跟踪 图像处理      更新时间:2023-10-16

我正在尝试找到在纯背景上跟踪不同颜色物体的最佳方法。

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

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

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

我也看过像cvBlob这样的库,但是我在尝试安装这些库时遇到了麻烦,所以我宁愿坚持使用纯粹的OpenCV实现。

作为旁注,我正在使用C++ OpenCV库。

这里有几个问题你需要问自己。您的问题表明您想要一个相当简单的跟踪算法。 你看过什么方法?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