OpenCV 4.0.0 SystemError: <class 'cv2.CascadeClassifier'> returned a result with an error set

孤人 提交于 2019-12-10 17:18:29

问题


Hello I am trying to create a facial recognition program but I have a peculiar error: here is my code:

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
face_cascade = cv2.CascadeClassifier("lbpcascade_frontalface.xml")
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=5);

and this error is the output

SystemError: <class 'cv2.CascadeClassifier'> returned a result with an error set

I have "lbpcascade_frontalface.xml" in the working directory so that shouldn't be an issue

if it helps when I enter

cv2.__version__

I get

'4.0.0'

回答1:


Turns out I didn't need to download another file and use it because opencv comes with it this little bit of code worked

cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")


来源:https://stackoverflow.com/questions/54273050/opencv-4-0-0-systemerror-class-cv2-cascadeclassifier-returned-a-result-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!