Blink Detection
- SDK.detect_blink(self: tfsdk.SDK, tf_image: tfsdk.TFImage, target_face: tfsdk.FaceBoxAndLandmarks) Tuple[tfsdk.ERRORCODE, tfsdk.BlinkState]
Determine if the eyes of the specified face are open or closed. Note, this function does not work well with eyeglasses, which can be detected using
tfsdk.SDK.detect_glasses()
.- Parameters:
tf_image - The input
tfsdk.TFImage
, returned bytfsdk.SDK.preprocess_image()
.target_face - The face on which to run blink detection.
- Returns:
tfsdk.ERRORCODE
- The error code. Note, if the face is not frontal facing, an error will be returned.tfsdk.BlinkState
- The output of the blink prediction.
- SDK.detect_blinks(self: tfsdk.SDK, tf_images: List[tfsdk.TFImage], keypoints_vec: List[Annotated[List[tfsdk.Point], FixedSize(106)]]) Tuple[tfsdk.ERRORCODE, List[tfsdk.BlinkState]]
Determine if the eyes of the specified faces are open or closed. This batch processing method increases throughput when using GPU inference.
- Parameters:
tf_images - A list of input images.
keypoints_vec - A list of the face landmarks for the faces on which to run blink detection.
- Returns:
tfsdk.ERRORCODE
- The error code.List[
tfsdk.BlinkState
] - List of outputs of the blink prediction.
- class tfsdk.BlinkState
- property is_left_eye_closed
Predicted result for the left eye being closed. Computed as
tfsdk.BlinkState.left_eye_score
< 0.5.
- property is_right_eye_closed
Predicted result for the right eye being closed. Computed as
tfsdk.BlinkState.right_eye_aspect_ratio
< 0.5.
- property left_eye_aspect_ratio
The aspect ratio of the left eye, computed as height / width.
- property left_eye_score
Score indicating if the left eye is open or closed. 0 indicates closed, 1 indicates open.
- property right_eye_aspect_ratio
The aspect ratio of the right eye, computed as height / width.
- property right_eye_score
Score indicating if the right eye is open or closed. 0 indicates closed, 1 indicates open.
- to_dict(self: tfsdk.BlinkState) dict
Return a dictionary representation of the object.
To reduce False Positives, blink detection must be run with several constraints:
Ensure the face is frontal facing
The face should be 1 - 3 ft from the camera
Recommended 640 x 480 resolution or better
Ensure there is good lighting illuminating the eyes
These constraints are not enforced by the method, and should be enforced by called of SDK for best results.