Skip to content

Commit

Permalink
Merge pull request ageitgey#1118 from ariyapour/blink-detection-fix
Browse files Browse the repository at this point in the history
Blink detection fix
  • Loading branch information
ageitgey authored Sep 26, 2020
2 parents 8ebc093 + 15ab2fa commit 186d64d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/blink_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import cv2
import time
from scipy.spatial import distance as dist
import keyboard as kb

EYES_CLOSED_SECONDS = 5

Expand Down Expand Up @@ -57,7 +56,6 @@ def main():
cv2.rectangle(small_frame, left_eye[0], right_eye[-1], color, thickness)

cv2.imshow('Video', small_frame)
cv2.waitKey(1)

ear_left = get_ear(left_eye)
ear_right = get_ear(right_eye)
Expand All @@ -75,11 +73,15 @@ def main():
while (asleep): #continue this loop until they wake up and acknowledge music
print("EYES CLOSED")

if (kb.is_pressed('space')):
if cv2.waitKey(1) == 32: #Wait for space key
asleep = False
print("EYES OPENED")
closed_count = 0

process = not process
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break

def get_ear(eye):

Expand Down

0 comments on commit 186d64d

Please sign in to comment.