CascadeClassifier::load function always returns false

asked Apr 30 '13

s4eed gravatar image

Hi. My CascadeClassifier::load function returns false even with an absolute path to the xml file :

face_cascade.load( "D:/tmp/haarcascade_frontalface_alt2.xml" );

I'm using opencv 2.4.5

Preview: (hide)

Comments

your code works with vs2010 and opencv 2.4.5 ... Maybe your path isn't correct ?

Rogeeeer gravatar imageRogeeeer (Apr 30 '13)edit

Are you sure that you have correctly created your face_cascade object? Also make sure you have no typo's. I use this code daily and do not see an immediate problem. Maybe add your complete code?

StevenPuttemans gravatar imageStevenPuttemans (Apr 30 '13)edit

If you are running in Windows, make sure that you are using slash () in the path. You are using the backslash (/), it is used in Linux environments.

icedecker gravatar imageicedecker (Apr 30 '13)edit

This is the most common mistake made by people. It was only for windows95 and earlier versions, you actually had to watch the backslash or frontslash problem. So this is not the case anymore in more recent versions like windows 7. However, when using backslashes \ , I advice you to use doubles \, because the backslash is the windows escape character. To avoid this, use frontslash, which works perfectly.

StevenPuttemans gravatar imageStevenPuttemans (May 2 '13)edit