I'm working on a project that detects eyes of the person in the sight of camera. I have used face_cascade and eye_cascade to determine it. It works fine with adjustable threshold. But if for some reason the whole face can not be detected after a while, the eye detection stops. For example if the eyes are detected once but now the person wears a helmet, though eyes are still visible but it becomes difficult to detect eyes without detecting the face first.
Can you please help and guide me on how the program can automatically search for eyes by setting up an ROI there once it has detected them earlier?
If that's not possible, then how to manually select ROI so that program looks for those particular areas only?
Thanks in advance
Code reference:
def main():
cap = cv2.VideoCapture(0)
time.sleep(1.000)
cv2.namedWindow('image')
cv2.createTrackbar('threshold', 'image', 0, 255, nothing)
while True:
_, frame = cap.read()
face_frame = detect_faces(frame, face_cascade)
if face_frame is not None:
eyes = detect_eyes(face_frame, eye_cascade)
for eye in eyes:
if eye is not None:
threshold = cv2.getTrackbarPos('threshold', 'image')
eye = cut_eyebrows(eye)
keypoints = blob_process(eye, threshold, detector)
eye = cv2.drawKeypoints(eye, keypoints, eye, (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv2.imshow('image', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()