close

[Solved] : (-215) !empty() in function detectMultiScale

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error : (-215) !empty() in function detectMultiScale in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How : (-215) !empty() in function detectMultiScale Error Occurs?

Today I get the following error : (-215) !empty() in function detectMultiScale in python.

How To Solve : (-215) !empty() in function detectMultiScale Error ?

  1. How To Solve : (-215) !empty() in function detectMultiScale Error ?

    To Solve : (-215) !empty() in function detectMultiScale Error The XML or file is missing or the path to it is incorrect or the create_capture path is incorrect.

  2. : (-215) !empty() in function detectMultiScale

    To Solve : (-215) !empty() in function detectMultiScale Error The XML or file is missing or the path to it is incorrect or the create_capture path is incorrect.

Solution 1

I had the same issue.

I didn’t need to download anything else to solve this. CV2 had everything I needed.

Instead of trying to figure out where the .xml files are and hard coding the values, I used a property given by cv2.

From OP

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')

Becomes

face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_eye.xml')

Solution 2

The XML or file is missing or the path to it is incorrect or the create_capture path is incorrect.

The paths in the opencv sample look like this:

cascade_fn = args.get('--cascade', "../../data/haarcascades/haarcascade_frontalface_alt.xml")
nested_fn  = args.get('--nested-cascade', "../../data/haarcascades/haarcascade_eye.xml")

cam = create_capture(video_src, fallback='synth:bg=../data/lena.jpg:noise=0.05')

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read