1 | initial version |
if you look at the code, they're already cropping a roi for the faces:
roi_color = img[y:y+h, x:x+w]
now you'll do the same, just for the eyes:
# global var:
eye_counter = 0
eyes = eye_cascade.detectMultiScale(roi_gray)
for (ex,ey,ew,eh) in eyes:
# here's your eye-roi, see, it's the very same pattern
roi_color_eye = roi_color[ey:ey+eh, ex:ex+ew]
# write image *before* drawing stuff on it
cv2.imwrite("eye_%d.png" % eye_counter, roi_color_eye)
eye_counter += 1
cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)