Liveness

ErrorCode Trueface::SDK::detectBlink(const Trueface::FaceBoxAndLandmarks &targetFace, BlinkState &blinkState)

Determine if the eyes of the specified face are open or closed. The default thresholds for this function have been selected to minimize False Positives (an open eye classified as a blink) at the expensive of increased False Negatives (a closed eye classified as an open eye). However, you can also choose your own thresholds based on the members of Trueface::BlinkState. Note, this function does not work well with eyeglasses, which can be detected using Trueface::SDK::detectGlasses.

Parameters
  • 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.

struct Trueface::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.3 && Trueface::BlinkState.leftEyeAspectRatio < 0.22.

bool isRightEyeClosed = false

Predicted result for the right eye being closed. Computed as Trueface::BlinkState.rightEyeScore < 0.3 && Trueface::BlinkState.rightEyeAspectRatio < 0.22.

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.

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

../_images/blink_detection_distance.png ../_images/blink_detection_lighting.png