我想检测一双眼睛,但是得到的结果是这样的: 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')