Ask Your Question

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

asked 2017-05-28 08:38:35 -0500

v108 gravatar image

updated 2019-02-12 14:56:49 -0500

LBerger gravatar image

Hi I'm relatively new to OpenCV and python in general and trying to create a face-detecting webcam using the code from

When I try to execute the code it returns with the following:

OpenCV Error: Assertion failed (!empty()) in detectMultiScale, file /home/pi/opencv-3.1.0/modules/ objdetect/src/cascadedetect.cpp, line 1639 Traceback (most recent call last): File "", line 29, in <module> minSize=(30, 30) cv2.error: /home/pi/opencv-3.1.0/modules/objdetect/src/cascadedetect.cpp:1639: error: (-215) !empt y() in function detectMultiScale

I'm just wondering what is causing this error and how to go about fixing it. Thanks in advance :)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-05-28 08:55:14 -0500

berak gravatar image

this means, that the CascadeClassifier did not find the cascade.xml file. either put it into the same place, where you run the python script, or adjust the path. also check again after loading like:

print( faceCascade.empty() )
edit flag offensive delete link more


Hey I've the same error, I couldn't even find the location of that cascade file. Here it shows it as D:\ but there's not even 1bit of data... its completely empty!! Please help me ASAP please!! I tried with my code as well as this code, but the same error Please help me!!

Traceback (most recent call last): File "C:/Users/notebook/Documents/Python Scripts/", line 20, in <module> flags=cv2.CASCADE_SCALE_IMAGE cv2.error: D:\Build\OpenCV\opencv-3.3.1\modules\objdetect\src\cascadedetect.cpp:1698: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

Vixel gravatar imageVixel ( 2017-11-29 02:43:44 -0500 )edit

@Vixel, what is unclear to you in the answer above ?

berak gravatar imageberak ( 2017-11-29 02:50:19 -0500 )edit

Thanks for your quick reply, You're answer looks great, but am not able to locate that file. The error says its in the D:\ drive, but my D drive is completely empty. Now what should I do?

Vixel gravatar imageVixel ( 2017-11-29 03:00:10 -0500 )edit

D:\Build\OpenCV\opencv-3.3.1\modules\objdetect\src <-- that's the location of the src file, when it was compiled, not the location of the cascade file.

try to locate e.g. haarcascade_frontalface.xml on your box, and give the absolute path to that to your CascadeClassifier

berak gravatar imageberak ( 2017-11-29 03:45:23 -0500 )edit

Thankyou thanks a lot!!!!!!!!! It worked Thankyou sooo much

Vixel gravatar imageVixel ( 2017-11-29 04:01:25 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-05-28 08:38:35 -0500

Seen: 5,658 times

Last updated: May 28 '17