Crowd Detection

Download source (project for a university class for which code wasn’t evaluated – as everything was made in a hurry, hope and comments have forsaken it – it’s really ugly; be warned!)
Download binary (note that the DLL needs to be placed where the binary for VirtualDub is…)

This time a project that was made for my studies – Digital Image Processing class to be more specific.
The aim of the project was to detect crowd on video monitoring – crowd means >= 2 people;) The system shouldn’t react to cars and other non-human movement.
We were told to analyze a few bits of literature, but the approaches presented there were rather complicated/too specific. So after some playing in Virtual Dub, we came with a pretty simple (engineer’s hack;) ) idea:

1) make everything as filters for Virtual Dub
2) use built-in Blur filter to “stabilize” the image
3) use custom (written by us) difference filter to extract movement
4) use custom edge detection filter to extract movement edges, separately horizontal and vertical
5) use custom field voting filter, to divide the image into potentially human/non-human/no motion parts
6) classify the potentially human parts as crowds or single persons (based on the area of the parts)
7) decide whether the crowd was detected or not.

Human field – more movement of “vertical edges”
Non human field – more movement of “horizontal edges”
Crowd detected – at least 2 separate people or at least one crowd (big enough human area)

The dimmensions of the separate areas were adjusted with “perspective correction” factor, based on the parameters of the camera and vertical position on the image.

In order to avoid false alarms we included some inertia in voting and decision making – much of it is configurable, but there are values that almost always work:)

Also, we added some postprocessing on the voting fields, to eliminate vertical edges of high vehicles (buses, vans etc.). It doesn’t work perfectly, but it does pretty well on the sample videos.

Thanks to OpenMP, after some tune-up, everything works in *almost* real time on my laptop (Core Duo 1.83GHz – no, not Core 2 Duo, that would be just too nice).

Some screens:

Diff filter

Diff + Edge detection

Diff + Edge detection

Diff + Edge detection + Field voting

Setup with values good for university courtyard sequence

For those of you without any psionic abilities:

red – non-human movement areas

blue – potentially human movement areas

dark green – big vehicle areas

light green – edges of big vehicle areas converted from “potentially human” movement areas

funny lines on the left side – visualisation of the correction factors

white rectangle in the lower left corner – “crowd detected” signal

white frames – crows/humans detected

Copyright’N’Stuff:

The project was made by:

Lurker_pas (me;) ) – idea and main code, testing
Marcin Iwiński – test data, testing, adjustment
Michał Mosdorf – perspective correction idea and code, documentation

for class CPOO – Cyfrowe Przetwarzanie Obrazów (Digital Image Processing) led by Piotr Garbat

Edge detection filter uses 5×5 Sobel kernel.

All filters (framework) were done based on the tutorial code supplied with the VirtualDub SDK.

If you want to use it – feel free to do so, but give us the credit:)

Cheers!


Leave a comment