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:
Is anyone able to provide guidance or samples for doing this - preferably in Python?
People detection OpenCV features an implementation for a very fast human detection method, called HOG (Histograms of Oriented Gradients). This method is trained to detect pedestrians, which are human mostly standing up, and fully visible. So do not expect it to work well in other cases. Now run the script.
We start by reading each frame of the video being played. We start the timer and use the tracker to estimate the trajectory of the object in the video. We use the tracker's estimated trajectory to draw the bounding box around the object of interest.
Object Detection in a Video Using OpenCVTo detect objects in an video, the primary step is to load the video file in the program. After loading the video file, we have to segregate the video data frame by frame and perform object detection using just like before.
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.
See src/cvaux/cvhog.cpp
for the implementation and samples/python/peopledetect.py
for a more complete python example (both in the OpenCV sources).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With