Skip to content

Instantly share code, notes, and snippets.

@easonlai
Created February 13, 2021 09:49
Show Gist options
  • Select an option

  • Save easonlai/04bc0ac050f7c6eea41078b259be0fb6 to your computer and use it in GitHub Desktop.

Select an option

Save easonlai/04bc0ac050f7c6eea41078b259be0fb6 to your computer and use it in GitHub Desktop.
# Measure value between Left eye bottom and top position
eyeLeftvalue = int(eyeLeftBottom['y']) - int(eyeLeftTop['y'])
# Define distance value for left eye blinking
eyeLeftcloseValue = 20
# Show Left Eye Blinking message if distance between top and bottom is lower than defined value
if eyeLeftvalue < eyeLeftcloseValue:
eyeLeftvalueMsg = cv2.putText(frame, "Left Eye Blinking", (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 1, (0, 0, 255), 1, cv2.LINE_AA)
cv2.imshow('face_landmarks', eyeLeftvalueMsg)
# Measure value between Right eye bottom and top position
eyeRightvalue = int(eyeRightBottom['y']) - int(eyeRightTop['y'])
# Define distance value for right eye blinking
eyeRightcloseValue = 20
# Show Right Eye Blinking message if distance between top and bottom is lower than defined value
if eyeRightvalue < eyeRightcloseValue:
eyeRightvalueMsg = cv2.putText(frame, "Right Eye Blinking", (50, 100), cv2.FONT_HERSHEY_TRIPLEX, 1, (0, 0, 255), 1, cv2.LINE_AA)
cv2.imshow('face_landmarks', eyeRightvalueMsg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment