People tracking with opencv in controlled environment


I have set up a downward looking camera over an area of individuals (about 5) in a controlled environment.

Using the opencv addon I am able to isolate each individual as a blob and then find its centre. (I am using lighting to create a clear contrast between user and white floor) All great so far.

However, I want to be able to ‘track’ the x,y of each individual as they move around. I.e. I want the program to keep track of who is who as time passes.

The solution I am coding compares the centre of the blobs from the last frame to the new frame. It tries to keep track of who is who by assuming the user can only pass a short distance between frames and hence x1,y1 if x2,y2 is in a close vicinity.

I’ve also been flicking through the OpenCV - Optical flow etc to see if I can find a solution there, but I am not finding an appropriate solution. Optical Flow seems to track multiple points on a human (which is not what I am searching for) and provides a vector result of the noticed movements.

Am I right in thinking Optical Flow is not the solution, or have I mis-understood the various tracking functions of Optical Flow?

Any pointers would be really helpful.


Hey, i have done the same thing as you, and didn’t do it with optical flow (and it can work pretty well), but then i found this movie, which shows that optical flow can be very very usefull for this. But haven’t tried to accomplish it myself

This is what I did for the software for Audience, see a screenshot here

Videos here

This post could be helpful to you.

Thanks all for the replies, they were a great help.

smallfly: the thread suggested was very helpful. I ended up utilising stefanix’s blob tracking code. The blob tracking classes in stefanix’s openCV implementation didn’t appear to make it to the addon. (I’m sure there is a good reason for that), so I’ve adapted the example to use 005 with the openCV addon.

Here is the stefanix’s blob tracking code example for 005. (Apologies if someone has already done this.)


I am going to spend some time looking at the Optical Flow solution to this challenge after this project. I can see from chrisoshea’s Audience pictures that there are significant advantages in using Optical Flow to overcome the ‘blob merges’ and ‘cross over’ challenges.

Much thanks - cookernz

Hi everyone!

I need to do a project that involves tracking people on a market square from an 45 angle above and from the side. The input is from a PAL or other good quality camera and a serious pc to render graphics on the position of these people. They can be slightly obscured by objects or other persons, moving or standing still.

Who has expierence with something like this and would like to offer his/her help in this project which does have some budget but not a very large one at this moment.

Kind regards,