Ask Your Question

OpenCV Pedestrian Counting

asked 2012-09-12 06:45:12 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.


Currently i am developing a pedestrian counter project using OpenCV+QT on linux. My idea about this process is;

  1. Capture Frames.

  2. Do Background Subtraction.

  3. Clear noises (erode, dilate).

  4. Find blobs (cvBlobslib) - foreground objects.

  5. For each blob, set ROI and search for pedestrians (LBP with detectMultiScale) in these blobs (for better performance).

  6. For each found pedestrian do a nested upper body search(Not sure) (better reliability).

  7. If same pedestrian is found on continuing frames (3-4 frames maybe) - add that area to camshift and track - mark as pedestrian.

  8. Exclude camshift tracked areas from blob detection for next frames.

  9. If a pedestrian crosses a line increment number.

I want to know if i am on the right track. Do you have any suggestions for this task, or do you think some other ways are better than mine, or are there unnecessary steps in my algorithm?

edit retag flag offensive close merge delete



Counting pedestrian is a difficult problem in a unconstrained scenario. Detecting and tracking pedestrians are also mostly open problems. As always, it would be nice if you could provide some image examples, then we can be more specific.

gfuhr gravatar imagegfuhr ( 2012-09-12 13:57:31 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-11-08 07:02:58 -0600

punnerud gravatar image

Old post with a lot of readers on an important topic

The problem should be broken up. The "simple" solution is to count moving objects and correct for moving directions: Multiple Object Tracking (OpenCV + C++)

To isolate people from counting dogs, cars etc. the solution can be improved by detecting just people. This kind of detection is often part of what is called "object detecion": A well known framework for this is YOLO - YOLO (Python+OpenCV+PyTorch)

edit flag offensive delete link more


Yeah use a cnn for complex objects. Yolo /Pytoch / Tensorflow'/ Caffe ist fine for this.

I personally like yolo most.

holger gravatar imageholger ( 2018-11-08 07:30:27 -0600 )edit

Question Tools

1 follower


Asked: 2012-09-12 06:45:12 -0600

Seen: 4,624 times

Last updated: Nov 08 '18