First time here? Check out the FAQ!

Ask Your Question
0

Cascade Classifier example not working

asked Feb 15 '13

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

Preview: (hide)

2 answers

Sort by » oldest newest most voted
3

answered Feb 18 '13

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!

Preview: (hide)

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 (Feb 22 '13)edit

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

Shoule101 gravatar imageShoule101 (Feb 22 '13)edit
0

answered Mar 2 '13

berak gravatar image

updated Mar 2 '13

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

Preview: (hide)

Question Tools

Stats

Asked: Feb 15 '13

Seen: 5,270 times

Last updated: Mar 02 '13