py
py copied to clipboard
Error running face_cascade.detectMultiScale
Following code from this file in celebrity recognition project does not work:
face_cascade = cv2.CascadeClassifier('./opencv/haarcascades/haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('./opencv/haarcascades/haarcascade_eye.xml')
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
faces
Error:
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-9-17af89ccf870> in <module>()
4 # eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_eye.xml')
5
----> 6 faces = face_cascade.detectMultiScale(gray, 1.3, 5)
7 faces
error: OpenCV(4.1.2) /io/opencv/modules/objdetect/src/cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'
firstly check-in your directory named as or similar to C:/Python/Lib/site-packages/cv2 XML files are present if they are, then instead of ./opencv/haarcascades/haarcascade_frontalface_default.xml use the same XML file name from your directory.
and if they are not present then firstly download that files in that directory. https://github.com/anaustinbeing/haar-cascade-files you can download it from here.