opencv光流后如何跟踪物体

opencv光流后如何跟踪物体

本文介绍了opencv光流后如何跟踪物体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在视频上进行光流动(lk)之后,基于此数据查找对象并对其进行跟踪的最佳方法是什么?

After doing optical flow (lk) on a video what's the best way to find the objects based on this data and track them?

这听起来似乎很笨拙,但是我希望能够在物体周围定义清晰的轮廓,因此,如果它是形状怪异的瓶子或能够检测边缘的东西.

This probably sounds very noobish, but I would like to be able to define a clear outline around objects, so if it's a weirdly shaped bottle or something to be able to detect the edges.

推荐答案

我不确定LK是不是最好的算法,因为它会计算稀疏的一组角点的运动,并且跟踪通常比密集的光流结果(例如Farneback或Horn Schunck).计算完流量后,第一步,您可以对其范数进行一些阈值处理(以保留移动部分),并尝试从此结果中提取连通区域.但是请注意,如果您没有要跟踪的对象的模型,那么您的任务将变得不容易.

I'm not sure LK is the best algorithm, since it computes the motion of a sparse set of corner-like points, and tracking behaves usually better from a dense optical flow result (such as Farneback or Horn Schunck). After computing the flow, as a first step, you can do some thresholding on its norm (to retain the moving parts), and try to extract connected regions from this result. But be warned that your tasks is not going to be easy if you don't have a model of the object you want to track.

另一方面,如果您主要对跟踪感兴趣,并且可以接受一些交互性,则可以查看camshift示例代码,以了解如何根据其外观选择和跟踪图像区域.

On the other hand, if you are primarily interested in tracking and a bit of interactivity is acceptable, you can have a look at the camshift sample code to see how to select and track an image region based on its appearance.

---编辑---

如果您的相机是静态的,请改用背景减法.使用OpenCV 2.4 beta,您必须在视频模块文档中查找BackgroundSubtractor类及其子类.

If your camera is static, then use background subtraction instead. Using OpenCV 2.4 beta, you have to look for the class BackgroundSubtractor and its subclasses in the video module documentation.

还请注意,光流可以是实时的(或不是很远),只要有很好的参数选择以及GPU实现即可.在Windows上,您可以使用 TU Graz/Gpu4Vision组中的flowlib. OpenCV还具有一些GPU密集的光流,例如gpu :: BroxOpticalFlow类.

Note also that optical flow can be realtime (or not very far) with good choices of parameters, and also with GPU implementation. On windows, you can use flowlib from TU Graz/Gpu4Vision group. OpenCV also has some GPU dense optical flow, for example the class gpu::BroxOpticalFlow.

---编辑2 ---

将单像素检测结合到大物体中是一项名为连接的组件标签的任务.有一个快速的算法,可以在OpenCV中实现.因此,这为您提供了一个管道:

Joining single-pixel detections into big objects is a task called connected component labelling. There is a fast algorithm for that, implemented in OpenCV. So this gives you a pipeline which is:

  • 运动检测(像素级)--->已连接的补偿.标记--->对象跟踪(添加运动信息,卡尔曼滤波的可能轨迹...).

但是我们必须在这里停止,因为我们很快就会超出您最初提出的问题的范围;-)

But we'll have to stop here, because we'll soon be far beyond the scope of your initial question ;-)

这篇关于opencv光流后如何跟踪物体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:37