从视频序列中进行单人跟踪

发布于 2025-01-01 08:51:31 字数 333 浏览 2 评论 0原文

作为我论文工作的一部分,我需要构建一个从视频或图像序列进行人体跟踪的程序,例如 KTHIXMAS 数据集,假设:

  • 光照保持不变
  • 场景中只出现一个人

该程序需要实时执行

我已经搜索了很多但仍然找不到好的解决方案。

请建议我一个好的方法或合适的现有程序。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

童话 2025-01-08 08:51:31

情况 1 - 如果摄像头是静态的

如果摄像头是静态的,则跟踪一个人非常简单。

您可以应用一种称为背景扣除的方法。

  1. 在这里,为了获得更好的效果,您需要来自相机的裸图像,其中没有人。这是背景。 (即使你没有这个背景图片也是可以的。但是如果你有的话就更好了。我会在最后告诉你如果没有背景图片该怎么办)

  2. 现在开始从相机捕获。拍摄第一帧,将两个图像都转换为灰度,平滑两个图像以避免噪音。

  3. 从框架中减去背景图像。

  4. 如果框架没有改变背景图像(即没有人),你会得到一个黑色图像(当然会有一些噪音,我们可以将其去除)。如果有变化,即人走进框架,您将得到一个人物和背景为黑色的图像。

  5. 现在为图像设置合适的阈值。

  6. 应用一些侵蚀来消除小颗粒噪音。之后应用膨胀。

  7. 现在找到轮廓。最有可能的是只有一个轮廓,即人。

  8. 找到质心或任何你想让这个人跟踪的东西。

现在假设您没有背景图像,您可以使用 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.

  1. 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)

  2. Now start capture from camera. Take first frame,convert both to grayscale, smooth both images to avoid noise.

  3. Subtract background image from frame.

  4. 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.

  5. Now threshold the image for a suitable value.

  6. Apply some erosion to remove small granular noise. Apply dilation after that.

  7. Now find contours. Most probably there will be one contour,ie the person.

  8. 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?

江挽川 2025-01-08 08:51:31

一种可能的解决方案是使用特征点跟踪算法。
看看这本书:
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.

情独悲 2025-01-08 08:51:31

上述方法:在简单干净的场景中,只有人行走的运动而绝对没有其他运动或照明变化的情况下,先进行简单的帧差分,然后进行膨胀和腐蚀即可。此外,您每帧都进行检测,而不是跟踪。在这种特定情况下,跟踪可能也不会更困难。移动方向和速度:您可以在差异图像上运行 Lucas Kanade。

其核心是,您需要一个人体探测器和一个跟踪器。跟踪器可以是基于点的(Lucas Kanade 或 Horn 和 Schunck),也可以使用卡尔曼滤波器或任何类型的边界框或斑点跟踪。

许多视觉问题都是不适定的,一些结构/约束有助于更快地解决问题。要问的问题很少有:

  1. 相机是否在移动:不是很容易,是:更难,具体什么工作取决于其他条件。
  2. 除了人之外,场景是否恒定
  3. 人大部分时间都面向正面/侧面:使用 viola jones 进行检测或训练一个(具有 Haar 或类似功能的 adaboost)以检测侧面。
  4. 您需要它在空间上有多精确,边界框会做到这一点,还是您需要轮廓:边界框:只需在具有 SAD(绝对差异之和)的邻域中进行搜索(智能地:))。轮廓:更严格,使用基于轮廓的跟踪器。
  5. 您是否需要“轨迹”或仅需要人在每一帧的位置、时间精度?
  6. 由于您需要实时性,我们在这里讨论的分辨率是多少:
  7. 场景是否像序列一样稀疏,还是会很混乱?
  8. 该序列中还有其他动作吗?
  9. 离线还是在线?

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 :

  1. Is the camera moving : No quite easy, Yes : Much harder, exactly what works depends on other conditions.
  2. Is the scene constant except for the person
  3. Is the person front facing / side-facing most of the time : Detect using viola jones or train one (adaboost with Haar or similar features) for side-facing face.
  4. How spatially accurate do you need it to be, will a bounding box do it, or do you need a contour : Bounding box : just search (intelligently :)) in neighbourhood with SAD (sum of Abs Differences). Contour : Tougher, use contour based trackers.
  5. Do you need the "tracklet" or only just the position of the person at each frame, temporal accuracy ?
  6. What resolution are we speaking about here, since you need real time :
  7. Is the scene sparse like the sequences or would it be cluttered ?
  8. Is there any other motion in the sequence ?
  9. Offline or Online ?
弱骨蛰伏 2025-01-08 08:51:31

如果您使用 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文