Ask Your Question
0

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

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

v108 gravatar image

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

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 https://github.com/shantnu/Webcam-Fac...

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 "test4.py", 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
0

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

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

Comments

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 https://realpython.com/blog/python/fa... Please help me!!

Traceback (most recent call last): File "C:/Users/notebook/Documents/Python Scripts/face_detection3.py", 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 -0600 )edit

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

berak gravatar imageberak ( 2017-11-29 02:50:19 -0600 )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 -0600 )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 -0600 )edit
1

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

Vixel gravatar imageVixel ( 2017-11-29 04:01:25 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 12,800 times

Last updated: May 28 '17