Blink Detection
-
ErrorCode Trueface::SDK::detectBlink(const TFImage &tfImage, const FaceBoxAndLandmarks &targetFace, BlinkState &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
Trueface::SDK::detectGlasses
.- Parameters:
tfImage – [in] The input image returned by preprocessImage().
targetFace – [in] The face on which to run blink detection.
blinkState – [out] The output of the blink prediction.
- Returns:
Error code, see ErrorCode. Note, if the face is not frontal facing, an error will be returned.
-
ErrorCode Trueface::SDK::detectBlinks(const std::vector<TFImage> &tfImages, const std::vector<Landmarks> &keypointsVec, std::vector<BlinkState> &blinkStates)
Determine if the eyes of the specified faces are open or closed. This batch processing method increases throughput when using GPU inference.
- Parameters:
tfImages – [in] A list of input images.
keypointsVec – [in] A list of the face landmarks for the faces on which to run blink detection.
blinkStates – [out] The output list of blink prediction results.
- Returns:
Error code, see ErrorCode. Note, if one of the face is not frontal facing, an error will be returned.
-
struct BlinkState
Results from blink detection. You can use the members of
Trueface::BlinkState
to set your own thresholds which work best for your camera and lighting conditions.Public Members
-
bool isLeftEyeClosed = false
Predicted result for the left eye being closed. Computed as
Trueface::BlinkState.leftEyeScore
< 0.5.
-
bool isRightEyeClosed = false
Predicted result for the right eye being closed. Computed as
Trueface::BlinkState.rightEyeScore
< 0.5.
-
float leftEyeScore = 0.f
Score indicating if the left eye is open or closed. 0 indicates closed, 1 indicates open.
-
float rightEyeScore = 0.f
Score indicating if the right eye is open or closed. 0 indicates closed, 1 indicates open.
-
float leftEyeAspectRatio = 0.f
The aspect ratio of the left eye, computed as height / width.
-
float rightEyeAspectRatio = 0.f
The aspect ratio of the right eye, computed as height / width.
-
bool isLeftEyeClosed = false
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.