Ask Your Question
0

OpenCV Error: Assertion failed (!empty()) in detectMultiScale

asked 2015-01-05 05:06:48 -0500

jla gravatar image

updated 2015-01-05 05:12:14 -0500

Hi, i am trying to work with the example from the face-detection tutorial: tutorial link

While i do so and try to execute the examplecode in python, the following error occurs:

OpenCV Error: Assertion failed (!empty()) in detectMultiScale, file /home/julian/Downloads/opencv-3.0.0-beta/modules/objdetect/src/cascadedetect.cpp, line 1580 Traceback (most recent call last): File "/home/julian/PycharmProjects/PicProcessingTutorial/Face_Detection.py", line 15, in <module> faces = face_cascade.detectMultiScale(gray, 1.3, 5) cv2.error: /home/julian/Downloads/opencv-3.0.0-beta/modules/objdetect/src/cascadedetect.cpp:1580: error: (-215) !empty() in function detectMultiScale

What could be the reason for the error, how should i react to fix it? Thank you for your time and advice,

regards

jla

edit retag flag offensive close merge delete

Comments

2

Have you loaded the classifier successfully?

FooBar gravatar imageFooBar ( 2015-01-05 05:13:52 -0500 )edit
1

your cascade-file was not loaded (probably not found).

berak gravatar imageberak ( 2015-01-05 05:17:49 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-01-05 05:18:22 -0500

updated 2015-01-05 05:21:18 -0500

This looks as if you don't load the classifier successfully from the file. Could you read it via CascadeClassifier::load(filename) and check that it returns true?

This is the code for the classifier: https://github.com/Itseez/opencv/blob...

The bool CascadeClassifier::empty() is in line 1553 and ::load is just below.

edit flag offensive delete link more

Comments

thanks for your fast answer. Since i'm using opencv as a wrapper and the programm is in python, i need a little heads up, how to call the CascadeClassifier::load() from pythoncode!? Thanks in advance

jla gravatar imagejla ( 2015-01-05 05:28:55 -0500 )edit

The Docu is here: http://docs.opencv.org/modules/objdet...

So just

face_cascade.load('haarcascade_frontalface_default.xml')
FooBar gravatar imageFooBar ( 2015-01-05 05:34:15 -0500 )edit

thank you,

test = face_cascade.load('haarcascade_frontalface_default.xml')

print(test)

returns false

jla gravatar imagejla ( 2015-01-05 05:45:30 -0500 )edit

ok. If this solved your problem, it would be nice if you accept my answer as correct.

FooBar gravatar imageFooBar ( 2015-01-05 05:50:36 -0500 )edit
1

Well, the solution is (for any readers experiencing the same problem): instead of

face_cascade.load('haarcascade_frontalface_default.xml')

writing the whole path like:

face_cascade.load('/home/user/.../haarcascade_frontalface_default.xml')

should do it, and you Sir FooBar helped ,me a lot. Thank you very much, here ist your correct answer :) Have a nice day!

jla gravatar imagejla ( 2015-01-05 05:59:29 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-01-05 05:06:48 -0500

Seen: 46,849 times

Last updated: Jan 05 '15