Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I want to detect closed eyes after it closed 3 seconds

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 "------------------------------------"