使用haarcasecade_mcs_eyepair_big.xml但无法检测到眼睛,如何解决?

时间:2019-04-22 15:42:23

标签: python opencv object-detection haar-classifier eye-detection

我想检测一双眼睛,但是得到的结果是这样的: https://i.imgur.com/5R8n4xd.jpg如何解决?这是我的代码

faces = face_cascade.detectMultiScale(gray, 1.3, 5)
if len(faces) == 0: return
for x, y, w, h in faces:
    roi_gray = gray[y:y + h, x:x + w]
    roi_color = img[y:y + h, x:x + w]
    eyes = eyePair_cascade.detectMultiScale(roi_gray)
    if len(eyes) == 0: return
    for (ex, ey, ew, eh) in eyes:
        eyes_roi = roi_color[ey: ey + eh, ex:ex + ew]
    # cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)

cv2.imwrite(outfile, eyes_roi)

def main():     return_eye_pair('bahagia.jpg','eye_pair.jpg')

0 个答案:

没有答案