Tracking people from webcam with OpenCV

Spent last weekend on #douhack (in Donetsk), I have been creating a program to count number of people walking through the street in front of web camera.

This appeared not such a simple task. To recognize moving objects I have used simple technique of background subtraction, when later frame with image capture from camera is subtracted pixel-by-pixel from previous image and revealing the regions which were moved from one frame to another.

More advanced algorithm described in documentation (see referenced works).

For tracking the person which moves I have tried a few techniques, camshift algorithm didn’t really helped. The reason for this is that algorithms doesn’t have enough “memory” capacity to track objects which are disappeared behind the other objects on the street. So I did a hack to linearize the movement of the person to estimate where moved object will appear again.

Here is demo how it works (pretty lame anyway):

http://www.youtube.com/watch?v=gcONLfkFSNM

Also Github link with sources:

https://github.com/mgalushka/pedestrians-traffic-calc

I strongly recommend this book to understand the basics of OpenCV and objects tracking (if pdf is not available – give me a shot and I will update link).

Big special thanks to  Mateusz Stankiewicz for his blog post regarding the topic.

8 thoughts on “Tracking people from webcam with OpenCV

  1. Hello, first of all, congratulations on your proyect i looks really good. I’m trying to do the same in eclipse, but i have no luck with PDE files instead of java files. Could you give me a hand with that,please? greetings from Argentina

  2. Не могу вкурить как использовать этот код. Это библиотека которую надо подключать к java-программе или самостоятельная программа которую надо как-то скомпилять?

Leave a Reply

Your email address will not be published.