Ask Your Question

Counting detected objects with Haar Cascade

asked 2016-08-10 11:54:59 -0500

marcosbontempo gravatar image

updated 2016-08-10 12:02:48 -0500


I'm using a Haar Cascade classifier to identify in a camera capture. Now I also want to count the detected faces, but I'm having some logical problems to do it.

First I tried to add the number of the detected faces in every frame. It didn't work because the same face is added again after a new frame. Other problem is that the Cascade sometimes fails and the face is not detected. I don't want to count these instabilities or detections that happen in only one frame.

Does anybody know how to implement a reliable algorithm to count objects detected by a Haar Cascade classifier?

Any tip will be very helpful,


edit retag flag offensive close merge delete



can it be, you're confusing "detection" (one time, per image) with "tracking" (long time, over several frames) ?

berak gravatar imageberak ( 2016-08-10 11:57:12 -0500 )edit

Sorry, my mistake @berak. You're right, I want to count the objects over several frames.

marcosbontempo gravatar imagemarcosbontempo ( 2016-08-10 12:05:02 -0500 )edit

again, just get on the magic bus ;)

berak gravatar imageberak ( 2016-08-10 12:10:28 -0500 )edit

My main doubt is how to count only one time a object while it stays on the video. In all my attempts I counted multiple times the same object.

marcosbontempo gravatar imagemarcosbontempo ( 2016-08-10 12:10:52 -0500 )edit

yes, that's a known (and quite a "solved") problem. again, you need to track your found objects over time (-> trackiing), refine your estimation (-> kalman), and finally reassign your objects (-> hungarian)

berak gravatar imageberak ( 2016-08-10 12:16:46 -0500 )edit

Is it too much hard? There are lot of videos:

marcosbontempo gravatar imagemarcosbontempo ( 2016-08-10 12:18:14 -0500 )edit

i never watch youtube vids, they're all about bragging.

(but yes, a lot of work ahead for you)

berak gravatar imageberak ( 2016-08-10 12:20:33 -0500 )edit

I'm thinking if there are some parameters that differ one person from the others. For example, if the distance between my eyes is 10 pixels, my algorithm can realize that I'm still in the video and don't count me again. What do you think @berak? Do you if there is a parameter or operation that I can use, like a histogram?

marcosbontempo gravatar imagemarcosbontempo ( 2016-08-10 12:37:08 -0500 )edit

i'm not exactly sure, what you're talking about now, but yes, e.g. CamShift is using histogram backprojection for tracking

berak gravatar imageberak ( 2016-08-11 01:05:47 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-10 12:02:34 -0500

berak gravatar image

updated 2016-08-10 12:04:07 -0500

a couple of keywords for furthur research:

  • tracking
  • Kalman Filter
  • Hungarian Algorithm
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-08-10 11:54:59 -0500

Seen: 720 times

Last updated: Aug 10 '16