问题描述
我有一个固定的摄像头,指向室内区域。人们将走过相机,在大约5米之内。使用 OpenCV ,我想检测个人走过的过去 - 我的理想返回是一个检测到的个人数组,包含边界矩形。
I have a camera that will be stationary, pointed at an indoors area. People will walk past the camera, within about 5 meters of it. Using OpenCV, I want to detect individuals walking past - my ideal return is an array of detected individuals, with bounding rectangles.
查看了几个内置示例:
- Python 示例都不适用
- C blob跟踪示例看起来很有前途,但不接受实时视频,这使得测试变得困难。
- C motempl示例也看起来很有前途,因为它从后续视频帧计算剪影。大概我可以使用它来找到强连接的组件,并提取单个blob和它们的边界框 - 但我仍然试图找出一种方法来识别在后续帧中找到的blob作为相同的blob。
- None of the Python samples really apply
- The C blob tracking sample looks promising, but doesn't accept live video, which makes testing difficult. It's also the most complicated of the samples, making extracting the relevant knowledge and converting it to the Python API problematic.
- The C 'motempl' sample also looks promising, in that it calculates a silhouette from subsequent video frames. Presumably I could then use that to find strongly connected components and extract individual blobs and their bounding boxes - but I'm still left trying to figure out a way to identify blobs found in subsequent frames as the same blob.
是否有任何人能够提供指导或样本,最好在 Python 中?
Is anyone able to provide guidance or samples for doing this - preferably in Python?
推荐答案
OpenCV最新的SVN版本包含一个基于HOG的行人检测的(未记录的)实现。它甚至带有一个预训练探测器和一个python包装。基本用法如下:
The latest SVN version of OpenCV contains an (undocumented) implementation of HOG-based pedestrian detection. It even comes with a pre-trained detector and a python wrapper. The basic usage is as follows:
from cv import *
storage = CreateMemStorage(0)
img = LoadImage(file) # or read from camera
found = list(HOGDetectMultiScale(img, storage, win_stride=(8,8),
padding=(32,32), scale=1.05, group_threshold=2))
请参阅 src / cvaux / cvhog.cpp
samples / python / peopledetect.py
获取更完整的Python示例(在OpenCV源中)。
See src/cvaux/cvhog.cpp
for the implementation and samples/python/peopledetect.py
for a more complete python example (both in the OpenCV sources).
这篇关于如何使用OpenCV检测和跟踪用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!