从视频序列中进行单人跟踪
作为我论文工作的一部分,我需要构建一个从视频或图像序列进行人体跟踪的程序,例如 KTH
或 IXMAS
数据集,假设:
- 光照保持不变
- 场景中只出现一个人
该程序需要实时执行
我已经搜索了很多但仍然找不到好的解决方案。
请建议我一个好的方法或合适的现有程序。
As a part of my thesis work, I need to build a program for human tracking from video or image sequence like the KTH
or IXMAS
dataset with the assumptions:
- Illumination remains unchanged
- Only one person appear in the scene
The program need to perform in real-time
I have searched a lot but still can not find a good solution.
Please suggest me a good method or an existing program that is suitable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
情况 1 - 如果摄像头是静态的
如果摄像头是静态的,则跟踪一个人非常简单。
您可以应用一种称为背景扣除的方法。
在这里,为了获得更好的效果,您需要来自相机的裸图像,其中没有人。这是背景。 (即使你没有这个背景图片也是可以的。但是如果你有的话就更好了。我会在最后告诉你如果没有背景图片该怎么办)
现在开始从相机捕获。拍摄第一帧,将两个图像都转换为灰度,平滑两个图像以避免噪音。
从框架中减去背景图像。
如果框架没有改变背景图像(即没有人),你会得到一个黑色图像(当然会有一些噪音,我们可以将其去除)。如果有变化,即人走进框架,您将得到一个人物和背景为黑色的图像。
现在为图像设置合适的阈值。
应用一些侵蚀来消除小颗粒噪音。之后应用膨胀。
现在找到轮廓。最有可能的是只有一个轮廓,即人。
找到质心或任何你想让这个人跟踪的东西。
现在假设您没有背景图像,您可以使用
cvRunningAvg
函数。它会查找您用来跟踪的视频中帧的运行平均值。但你显然可以理解,如果你得到背景图像,第一种方法更好。这里是使用 cvRunningAvg 的上述方法的实现。
情况 2 - 相机不是静态的
这里背景减法不会给出好的结果,因为你无法获得固定的背景。
然后 OpenCV 附带了一个用于人员检测的示例。使用它。
这是文件: peopledetect.cpp
我还建议您访问这个 SOF,它处理几乎相同的问题:如何使用 OpenCV 检测和跟踪人员?
Case 1 - If camera static
If the camera is static, it is really simple to track one person.
You can apply a method called background subtraction.
Here, for better results, you need a bare image from camera, with no persons in it. It is the background. ( It can also be done, even if you don't have this background image. But if you have it, better. I will tell at end what to do if no background image)
Now start capture from camera. Take first frame,convert both to grayscale, smooth both images to avoid noise.
Subtract background image from frame.
If the frame has no change wrt background image (ie no person), you get a black image ( Of course there will be some noise, we can remove it). If there is change, ie person walked into frame, you will get an image with person and background as black.
Now threshold the image for a suitable value.
Apply some erosion to remove small granular noise. Apply dilation after that.
Now find contours. Most probably there will be one contour,ie the person.
Find centroid or whatever you want for this person to track.
Now suppose you don't have a background image, you can find it using
cvRunningAvg
function. It finds running average of frames from your video which you use to track. But you can obviously understand, first method is better, if you get background image.Here is the implementation of above method using cvRunningAvg.
Case 2 - Camera not static
Here background subtraction won't give good result, since you can't get a fixed background.
Then OpenCV come with a sample for people detection sample. Use it.
This is the file: peopledetect.cpp
I also recommend you to visit this SOF which deals with almost same problem: How can I detect and track people using OpenCV?
一种可能的解决方案是使用特征点跟踪算法。
看看这本书:
Laganiere Robert - OpenCV 2 计算机视觉应用编程手册 - 2011
p。 266
本书已经使用opencv实现了完整的算法。
One possible solution is to use feature points tracking algorithm.
Look at this book:
Laganiere Robert - OpenCV 2 Computer Vision Application Programming Cookbook - 2011
p. 266
Full algorithm is already implemented in this book, using opencv.
上述方法:在简单干净的场景中,只有人行走的运动而绝对没有其他运动或照明变化的情况下,先进行简单的帧差分,然后进行膨胀和腐蚀即可。此外,您每帧都进行检测,而不是跟踪。在这种特定情况下,跟踪可能也不会更困难。移动方向和速度:您可以在差异图像上运行 Lucas Kanade。
其核心是,您需要一个人体探测器和一个跟踪器。跟踪器可以是基于点的(Lucas Kanade 或 Horn 和 Schunck),也可以使用卡尔曼滤波器或任何类型的边界框或斑点跟踪。
许多视觉问题都是不适定的,一些结构/约束有助于更快地解决问题。要问的问题很少有:
The above method : a simple frame differencing followed by dilation and erosion would work, in case of a simple clean scene with just the motion of the person walking with absolutely no other motion or illumination changes. Also you are doing a detection every frame, as opposed to tracking. In this specific scenario, it might not be much more difficult to track either. Movement direction and speed : you can just run Lucas Kanade on the difference images.
At the core of it, what you need is a person detector followed by a tracker. Tracker can be either point based (Lucas Kanade or Horn and Schunck) or using Kalman filter or any of those kind of tracking for bounding boxes or blobs.
A lot of vision problems are ill-posed, some some amount of structure/constraints, helps to solve it considerably faster. Few questions to ask would be these :
如果您使用 .NET 进行开发,则可以使用 Aforge.NET 框架。
http://www.aforgenet.com/
我是论坛的常客,我似乎记得那里很多人用它来追踪人。
我还将该框架用于其他不相关的目的,并且可以说我强烈推荐它,因为它易于使用且功能强大。
If you develop in .NET you can use the Aforge.NET framework.
http://www.aforgenet.com/
I was a regular visitor of the forums and I seem to remember there are plenty of people using it for tracking people.
I've also used the framework for other non-related purposes and can say I highly recommend it for its ease of use and powerful features.