error starting CascadeClassifier with xml file

asked 2018-04-17 13:38:55 -0600

guerreiro gravatar image

updated 2018-04-17 13:48:53 -0600

berak gravatar image

I am trying to initialize my Cascade classifier with cascade = cv2.CascadeClassifier(xml_path)

But it raises the error

OpenCV Error: Unknown error code -49 (Input file is empty) in cvOpenFileStorage, file C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp, line 4484
cv2.error: C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp:4484: error: (-49) Input file is empty in function cvOpenFileStorage

I have just downloaded the xml file from https://github.com/opencv/opencv/tree...

What am I missing?

edit retag flag offensive close merge delete

Comments

check the file size on disk again. the error msg might be true, and your download was broken

berak gravatar imageberak ( 2018-04-17 13:50:04 -0600 )edit

thank you for your reply, the file size is ok (~6MB)

guerreiro gravatar imageguerreiro ( 2018-04-17 13:51:59 -0600 )edit

no cascade of that size exists. and which one is it, exactly ?

(seems, it failed to find a valid xml or yml signature)

berak gravatar imageberak ( 2018-04-18 01:55:03 -0600 )edit

It is the haarcascade_frontalcatface.xml

guerreiro gravatar imageguerreiro ( 2018-04-19 07:31:32 -0600 )edit

again, the size is wrong, and it does not seem to be valid xml. something's wrong with your file.

berak gravatar imageberak ( 2018-04-19 07:39:11 -0600 )edit

thank you! good to know, it helps to know where is problem, I will look into it!

guerreiro gravatar imageguerreiro ( 2018-04-19 07:57:11 -0600 )edit

try to open it in a text editor, or do something like:

head -c 2000 mycascade.xml

i'm sure, it's not , what you expected

berak gravatar imageberak ( 2018-04-19 07:59:05 -0600 )edit

@berak thank you so much, I was just being stupid, it really was not what I was expecting and I missed to check that. Thank you!

guerreiro gravatar imageguerreiro ( 2018-04-19 09:03:10 -0600 )edit