Ask Your Question
0

How to count person in video?

asked 2014-09-02 00:45:38 -0600

Andrew1108 gravatar image

I am use opencv 2.4.9 and python 2.7.6, I need to count people in video. What I already did is:

  1. Background subtraction
  2. Find contour and put the bounding box
  3. Find the centroid (cx,cy)
  4. Draw a virtual line at (20,75) to (320,75)

I am trying to count people, when they cross the line. I try this code to count it

if 75 <= cy <=77:
   counter=counter+1

no error, but the counter count it double, Is there other way to count it?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2014-09-02 04:17:25 -0600

rahulvg gravatar image

i think you "if" check should be
if cy >= 75: counter=counter+1;

Why dont you use the haar cascade to detect face which will return you a rectangle per person instead of detecting contours....

edit flag offensive delete link more

Comments

I know there's haar cascade, but I got project using background subtraction, other team got count people with haar cascade.. Your code just multiplying the counter from cy>=75 until the cy leave the frame...

Andrew1108 gravatar imageAndrew1108 ( 2014-09-02 08:19:23 -0600 )edit
0

answered 2014-09-03 03:15:43 -0600

jestshen gravatar image

image description

like that? or you can detecting body information.

edit flag offensive delete link more

Comments

my video contain people walking.. I already done the bounding box, what I want how to count people when people cross the line.. like this picture http://picpaste.com/hqdefault-6g0Hqttu.jpg

Andrew1108 gravatar imageAndrew1108 ( 2014-09-03 07:32:12 -0600 )edit
0

answered 2015-03-30 00:41:54 -0600

Maybe your the centroid of the persons stays in the "75 >cy < 77" range for more than one frame that is why your counter is counting double

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-09-02 00:45:38 -0600

Seen: 5,815 times

Last updated: Sep 03 '14