Ask Your Question
0

Cascade Classifier example not working

asked 2013-02-15 10:26:09 -0600

Shoule101 gravatar image

Hi all, Im new to Opencv and was trying to run the object detection tutorial using cascade classifier. link here to tutorial link text

I can get the project to compile and run perfectly except it does not show the circles when going into the detectAndDisplay function.

When I use breakpoints to find out why. It shows that the vector<rect> faces is empty. So the for loops never execute and they dont draw the circles around a face.

I wonder if there is something missing here? Im trying to figure out how use detectMultiScale() but cant find examples.

Any help would be much appreciated. Sonny

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-02-18 12:10:45 -0600

benzun gravatar image

String face_cascade_name = "haarcascade_frontalface_alt.xml"; String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";

you need to replace these strings with the actual location of the cascades they will mostly be in the location where you installed opencv. Or copy them to your directory. If you dont point to the correct address for the cascade it wont work!

edit flag offensive delete link more

Comments

Hi, I've made sure that the xml files are in the right place. Ive tried using the full path. Placing them in the directory of the project but nothing works.

Shoule101 gravatar imageShoule101 ( 2013-02-22 09:32:14 -0600 )edit

Ive placed them in the directory and still it loads not load.

Shoule101 gravatar imageShoule101 ( 2013-02-22 10:07:02 -0600 )edit
0

answered 2013-03-02 15:48:38 -0600

berak gravatar image

updated 2013-03-02 16:11:46 -0600

the 2 main reasons i found, why this might fail are:

  • the cascade file was not found ( see all the other comments / answers ) might sound overly obvious, but the sad story here is:

    • of all devs, that believe in the general idea, only 5% actually implement the check ...

      if ( ! detect.load("cascade.xml") ) explode();

  • the image you supply to the actual detection is invalid(!) or not grayscale (1channel, 8bit)

    yes, you'll want a color version around for drawing things into, but make sure, the img you pass to cascade.detectMultiScale() or similar is actually grayscale

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-15 10:26:09 -0600

Seen: 5,165 times

Last updated: Mar 02 '13