Page 1 of 1

Counting Vehicles

Posted: Thu Nov 24, 2011 3:21 pm
by rossmck
Bit of an unusual use case ... but I was wondering if anyone could advise if ZoneMinder could be used for this (or if they could recommend anything else)

I have a camera overlooking a two lane road and am looking to count vehicles in each direction - essentially all I need is an output from zone minder which tells me when movement was detected in one of 4 zones (an "in" and "out" point on each side of the road) if this makes any sense.

The idea being I can use these values to work out how many vehicles entered the left hand side of the top of the image and left by the right hand side of the top of the image as traffic going one direction, and vice-versa using the bottom two.

Or can anyone think of how else this could possibly be achieved (within linux)

Re: Counting Vehicles

Posted: Thu Nov 24, 2011 11:51 pm
by bb99
Define 4 monitors using the same camera defining unique zones that cover only the desired area. I haven't done this but it's possible. Most I've setup is 2 monitors on same camera with different zones.

Re: Counting Vehicles

Posted: Sat Dec 03, 2011 2:44 am
by koolb
Sounds viable, if you use zmu -l to list notice when your left monitor (same cam) is pre-alarm after your right one, then you know the direction (car travels right to left).

while :
do sudo zmu -l -U $usr -P $pwd
done | perl -pe 'BEGIN{$left=1;$right=3;} #set to the appropriate left/right mon ids
($id, $fn, $st) = split(/\s+/);
next unless $fn == 3 && $st < 2 && ($id == $left || $id == $rite);
$st{$id} = $st;
if ($st{$left} > $st{$rite}) { print "car moving leftToRight\n"; }
elsif ($st{$rite} > $st{$left}) { print "car moving rightToLeft\n" }'