5

Hi I am new to OpenCV and I am trying to implement human body tracking using a camera placed on a fixed position. I did a bit of a research and I came across Histogram of Oriented Gradients method but based on my understanding what it does is detection instead of tracking. Therefore I was wondering what is the simplest way to implement human detection and tracking on OpenCV?

P/S: I found this video and it is precisely what I wanted to achieve.

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153
user2900552
  • 105
  • 1
  • 3
  • 7

2 Answers2

4

you can also try using a HAAR cascade for human body detection. just load the cascade using CascadeClassifier::CascadeClassifier() and then use CascadeClassifier::detectMultiScale() to obtain the regions within the given image where the object (body) was detected. adjust the parameters given to detectMultiScale() to speed up and increase accuracy of detection.

you can find a bunch of cascades here including one for body detection.

have a look at these SO posts:

Community
  • 1
  • 1
samkhan13
  • 3,315
  • 2
  • 33
  • 54
  • Thanks for the detailed suggestion but if its not too troubling I have one follow-up question. Does the method you suggested "simulate" tracking by quick re-detection as I wanted to put an unique identifier for every person I am tracking (as shown in the video above) on the real time video feed. Is it possible using your method? Thanks again. – user2900552 Nov 01 '13 at 08:16
  • @user2900552 using HAAR or LBP cascades you will only be able to detect regions within each camera frame which resemble the desired object. so yes, you "re-detect" in each frame and can thereby do tracking. assigning a unique id to an instance of the desired object requires the use of Principal Component Analysis or Linear Discriminate Analysis or "feature detection and feature matching". look for a book called "mastering opencv with practical computer vision projects". it has c++ recipies for what you need. – samkhan13 Nov 02 '13 at 15:45
  • Thanks for the kind reply. I will definitely try your suggestions but for now I really need to ramp up on OpenCV first. Thanks again. – user2900552 Nov 05 '13 at 12:12
  • Your link to the `bunch of cascades` are not working. Can you please update with the new link? – PeakGen Jul 01 '14 at 07:25
1

You can use HOG detector or latent svm detector with the "person" model to get the bounding box of the person and then track the person.

Tracking the centroid of the person can be done through the following: Measure the new centroid location. Measure it's velocity. Predict the next frame centroid's location using the current frame location and velocity. Then check if the new measurement of the centroid is close to the prediction. If it is then it's the same person as in the previous frame, if not then it's a new person that entered the frame.

Perhaps you should track the bounding box instead of the centroid. You the frame rate is high enough, perhaps you could just plot the bounding box and forget about tracking.

GilLevi
  • 2,117
  • 5
  • 22
  • 38