我有一个固定的相机,指向室内区域.人们会在距离它约 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.
我查看了几个内置示例:
I've looked at several of the built-in samples:
有没有人可以提供指导或示例 - 最好是在 Python 中?
Is anyone able to provide guidance or samples for doing this - preferably in Python?
最新的 SVN 版本的 OpenCV 包含一个(未记录的)基于 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))
因此,您可以在每一帧中运行检测器并直接使用其输出,而不是跟踪.
So instead of tracking, you might just run the detector in each frame and use its output directly.
请参阅 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 检测和跟踪人员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!