I want to detect closed eyes after it closed 3 seconds [closed]
This is a program to detect eyes closed. But i want after eyes closed 3 seconds, it will print "Warning" in terminal.
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x + w, y + h), (255, 255, 0), 2)
roi_gray = gray[y:y+h, x:x+w]
roi_color = image[y:y+h, x:x+w]
eyes = eyesCascade.detectMultiScale(roi_gray)
if eyes is not():
for (ex,ey,ew,eh) in eyes:
cv2.rectangle(roi_color,(ex -10 ,ey - 10),(ex+ew + 10,ey+eh + 10),(0,255,0),2)
twoeyes = twoeyesCascade.detectMultiScale(roi_gray)
checkyeys = 0
if twoeyes is not():
for (exx,eyy,eww,ehh) in twoeyes:
checkyeys = 0
led.write(1)
cv2.rectangle(roi_color,(exx-5 ,eyy -5 ),(exx+eww -5,eyy+ehh -5 ),(0,0, 255),2)
else:
#when eyes close
print "------------------------------------"
And how do you think this will work? The cascade will trigger way to many false positives on closed eyes to ever get this to work. It is not robust enough for this task.
You can suggest a few alternatives feasible.
I think "eyes = eyesCascade.detectMultiScale(roi_gray)" will detect eyes area And " twoeyes = twoeyesCascade.detectMultiScale(roi_gray)" will detect two eyes. When I see eyes area but don't see two eyes that's when detect closed eyes.
That won't work. Also, I only know of a right and left eye model and a general eye model, but there isn't a combined one. So where did you get that model?
Thanks you! How to you know if eyes closed in 3 seconds
For that you will need to either