Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

faces = face_cascade.detectMultiScale(gray, 1.3, 5)

About the code below:

import cv2

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')

img = cv2.imread('2.jpg')

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)

Im getting the following error

Traceback (most recent call last):
File "C:\Users\henri\.p2\pool\plugins\org.python.pydev_5.8.0.201706061859\pysrc\pydevd.py", line 1557, in <module>
cv2.error: C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1681: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

Things I tried without success:

  • The whole path in the xml file im using
  • Put explicit parameters like img=something

Obs: The dtype of variable gray its already uint8

faces = face_cascade.detectMultiScale(gray, 1.3, 5)

About the code below:

import cv2

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')

img = cv2.imread('2.jpg')

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)

Im getting the following error

Traceback (most recent call last):
File "C:\Users\henri\.p2\pool\plugins\org.python.pydev_5.8.0.201706061859\pysrc\pydevd.py", line 1557, in <module>
cv2.error: C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1681: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

Things I tried without success:

  • The whole path in the xml file im using
  • Put explicit parameters like img=something

Obs: The dtype of variable gray its already uint8