我尝试在 python 2.7中学习 cv2,但是当我运行我的代码时,在它的特定部分:
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
img = cv2.imread('2015-05-27-191152.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
它返回的结果是:
File "face_detection.py", line 11, in <module>
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
cv2.error: /home/arthurckl/Desktop/opencv-3.0.0-rc1/modules/objdetect/src/cascadedetect.cpp:1595: error: (-215) !empty() in function detectMultiScale
我试图在这里寻找答案,但我能找到的最好的是,我必须加载的脸级联错误的方式... 有什么帮助吗?