斑点跟踪算法 [英] Blob tracking algorithm

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

问题描述

我正在尝试使用 OpenCV 创建简单的 blob 跟踪.我已经使用 findcontours 检测到了这些斑点.我想给这些 blob 一个常量 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 和当前帧之间的距离.我想知道还需要什么来跟踪 blob 并给它们一个 ID.我只是获取了前一帧和当前帧 blob 之间的距离,但是如何使用 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 代表第二个...他们在收藏中的位置.

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.刚刚进入该字段的 Blob 将获得新的 ID.

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 个图像的位置.对于第一帧的任何斑点,在第 2 帧上寻找最近​​的斑点,计算速度(deltaX deltaY),寻找最接近第 3、4、5 帧的预测位置...总结预测位置和最近斑点之间的所有距离成为分数.使用第 2 帧上的第 2 个最近点执行相同操作(它将向另一个方向搜索).分数越低,它最有可能是好的 blob.

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.

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

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