CascadeClassifier::load function always returns false

asked 2013-04-30 03:55:07 -0600

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

edit retag flag offensive close merge delete

Comments

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

Rogeeeer gravatar imageRogeeeer ( 2013-04-30 05:10:58 -0600 )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 ( 2013-04-30 08:22:32 -0600 )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 ( 2013-04-30 17:52:12 -0600 )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 ( 2013-05-02 01:58:15 -0600 )edit