Blob跟踪算法

扫码查看
本文介绍了Blob跟踪算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用OpenCV创建简单的blob跟踪。我已经使用findcontours检测到blob。我想给那些blobs一个恒定的ID。

I'm trying to create simple blob tracking using OpenCV. I have detected the blobs using findcontours. I would like to give those blobs a constant ID.

我收集了前一帧和当前帧中的blob列表。然后我取上一帧中的每个斑点和当前帧之间的距离。我想知道还需要什么来跟踪blob和给他们一个ID。我只是把前一帧和当前帧之间的距离blob,但是如何使用测量到的blob之间的距离来分配一个一致的ID?

I have collected a list of blobs in the previous frame and the current frame. Then I took the distance between each blob in the previous frame and the current frame. I would like to know what else is needed to track the blobs and give them an ID. I just took the distance between previous and current frame blobs, but how can I assign the blobs a consistent ID using the measured distance between the blobs?

推荐答案

在第一个框架中,您可以以任何方式分配id,第一个找到的值为1,第二个值为2 ...或者根据它们在集合中的位置给予ID。

In the first frame, you can assign id any way, 1 for the first you find, 2 for the second... or simply give them ID according to their position in the collection.

然后在下一帧,你必须使用最佳匹配。找到blob,计算当前blob和前一个图像的所有blob之间的所有距离,并将每个先前的ID分配给最近的blob。

Then on next frame you will have to use best match. Find the blobs, compute all distances between current blobs and all the blobs of the previous image and assign each previous ID to the closest blob. Blobs that just enter the field will get new IDs.

现在你有两个框架,你可以为下一个框架做运动预测。只需计算blob的上一个和当前位置之间的deltaX和deltaY。您可以使用此信息来猜测未来的位置。匹配这个未来的位置。

Now you have two frames, you can do movement prediction for the next one. Just compute deltaX and deltaY between previous and current position of the blob. You can use this information to guess future position. Match against this future position.

如果你没有太多的重叠blob,以及如果移动不是太快和每帧之间不稳定,这应该工作。

This should work if you have not to many overlapping blobs, and if movement is not too fast and erratic between each frames.

通过几个图像使用评分系统可以更准确:

获取前3或5张图像的位置。对于帧1的任何斑点,寻找最接近帧2,计算速度(deltaX deltaY),寻找最接近帧3,4,5 ...的预测位置...累加预测位置和最接近的斑点之间的所有距离是得分。使用第2帧最近的第2帧(它将在另一个方向搜索)。

It's possible to be more accurate using a scoring system trough several images:
Get positions for the first 3 or 5 images. For any blob of frame one, seek the closest on frame 2, compute the speed (deltaX deltaY), seek the closest to predicted position for frame 3, 4, 5... Sum up all distances between predicted positon and closest blob it will be the score. Do the same using the 2nd closest on frame 2 (it will seek in another direction). The lower the score the most likely its the good blob.

如果你有很多blob,你应该使用四叉树加速过程。比较平方距离;它将避免大量的sqrt计算。

If you have lot of blobs, you should use a quadtree to speedup process. Compare squared distance; it will avoid lot of sqrt computations.

重要的是要知道你的blob如何移动来调整你的协商。

It's important to know how your blob tipically move to tune your algotrithm.

这篇关于Blob跟踪算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:51
查看更多