使用 OpenCV 检测越线人员
我想统计从两边越线的人数。我有一个放置在天花板上的摄像机,拍摄线条所在的地板(因此摄像机只能看到人的头顶;因此它更多的是物体检测而不是人检测)。
是否有针对此问题或类似问题的示例解决方案?那我可以向他们学习吗?
编辑1:任何时刻都有不止一个人越线。
I want to count number of people crossing a line from either side. I have a camera that is placed on ceiling and shooting for the floor where the line is (So camera sees just top of people heads; and so it is more of object detection than people detection).
Is there any sample solution for this problem or similar problems like this? So I can learn from them?
Edit 1: More than one person is crossing the line at any moment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果除了人类之外没有其他东西可以越线,那么您不需要检测人,您只需检测运动即可。
运动蛋白检测有多种方法。
也许最简单的一种就适合您的目标。您只需计算视频流的连续帧之间的差异,然后通过这种方式确定“运动掩模”,从而检测线交叉事件
作为此“算法”的改进,您可以考虑“运行平均”方法。
要确定运动方向,您可以使用“运动模板”。
为了提高探测器的准确性,您可以尝试任何背景扣除技术(这又不是一个简单的解决方案)。例如,如果有一些移动背景应该被过滤掉(例如使用统计学习)
所有提到的算法都包含在OpenCV库中。
UPD:
cvSegmentMotion
、cvUpdateMotionHistory
(搜索文档)。 OpenCV 库包含运动分析的示例代码,请参阅 motempl.cIf nothing else but humans are subject to cross the line then you need not to detect people you only have to detect motion.
There are several approaches for motoin detection.
Probably the simplest one fits your goals. You simply calculate difference between successive frames of video stream and this way determine "motion mask" and thus detect line crossing event
As an improvement of this "algorithm" you may consider "running average" method.
To determine a direction of motion you can use "motion templates".
In order to increase accuracy of your detector you may try any background subtraction technique (which in turn is not a simple solution). For example, if there is some moving background which should be filtered out (e.g. using statistical learning)
All algorithms mentioned are included in OpenCV library.
UPD:
cvCalcMotionGradient
,cvSegmentMotion
,cvUpdateMotionHistory
(search docs). OpenCV library contains example code for motion analysis, see motempl.c我不是基于视频的简历方面的专家,但如果您可以将问题简化为一组有限的图像(例如,进入帧、站立、退出帧),那么您可以使用多种形状识别算法之一。我知道形状上下文很好,但我怀疑它对于这个应用程序是否足够微妙(它无法区分头部和大多数其他圆形物体)。
基本上,尝试从视频中提取关键图像,然后使用形状识别算法对其进行测试。
PS 通过良好的运动检测方法可能可以找到关键图像。
I'm not an expert in video-based cv, but if you can reduce the problem into a finite set of images (for instance, entering frame, standing on line, exiting frame), then you can use one of many shape recognition algorithms. I know of Shape Context which is good, but I doubt if it subtle enough for this application (it won't tell the difference between a head and most other round objects).
Basically, try to extract key images from the video, and then test them with shape recognition algorithms.
P.S. Finding the key images might be possible with good motion detection methods.