Skip to content

About best shot estimations#

This section explains how LUNA ID POS evaluates image quality to get the best shot from a video stream.

How it works#

LUNA ID POS analyzes each frame of a video stream captured by your device's camera, searching for a face. For accurate evaluation, each frame must contain only one face. Frames with faces that pass specific estimations are considered the best shots.

If an estimation fails, the corresponding error message is returned.

The minimum camera resolution required for optimal estimator performance is 720p (1280x720 pixels).

The LunaID.allEvents() event (or the more specialized LunaID.finishStates()) emits the ResultSuccess event containing the best shot found and an optional path to the recorded video.

You can adjust parameters for best shot estimations in LunaConfig.kt.

Estimations#

LUNA ID POS performs several estimations to determine if an image qualifies as the best shot.

Number of faces in the frame#

The estimation ensures that the frame contains only one face. If multiple faces are detected, the system returns a TooManyFacesError error message.

By default, no value is set for this estimation.

AGS estimation#

The estimation calculates a score indicating the suitability of the source image for descriptor extraction and matching. The output is a normalized float score ranging from 0 to 1. A score closer to 1 indicates better matching results for the image.

By default, the AGS threshold is set to 0.5.

Implementation: public val ags: Float = DEFAULT_AGS

Head pose estimation#

The estimation determines a person's head rotation angles in 3D space, specifically along the pitch, yaw, and roll axes:

  • Pitch (X-axis): This angle measures the vertical tilt of the head. It limits the head rotation along the X-axis.
  • Yaw (Y-axis): This angle measures the horizontal rotation of the head. It limits the head rotation along the Y-axis.
  • Roll (Z-axis): This angle measures the lateral tilt of the head. It limits the head rotation along the Z-axis.
Head pose
Head pose

By default, all rotation angles (pitch, yaw, and roll) are set to 25 degrees each side.

Implementation:

Angle Implementation
Pitch public val headPitch: Float = DEFAULT_HEAD_PITCH
Yaw public val headYaw: Float = DEFAULT_HEAD_YAW
Roll public val headRoll: Float = DEFAULT_HEAD_ROLL

Image quality estimation#

The estimation evaluates an image based on several key criteria to ensure it meets the necessary standards. These criteria include:

  • Blurriness: The image appears out of focus.
  • Underexposure: The image is too dark.
  • Overexposure: The image is too bright.

Below are the default values for each criterion used in the image quality estimation:

Parameter Default value
Blurriness 0.61
Lightness 0.57
Darkness 0.50

Face detection bounding box size#

The estimation ensures that the detected face's bounding box matches a specified size. This estimation helps determine if the subject is too far from the camera, affecting image quality.

The minimum recommended size for the face bounding box is 200 x 200 pixels.

The default value is 350 dp (density-independent pixels).

Warning

If the converted pixel value is less than 100 pixels, the frame size will automatically be set to 100 pixels to maintain a minimum acceptable quality.

Here are the configuration details for setting the minimum detectable frame size: public const val DEFAULT_MIN_DETECT_FRAME_SIZE: Int = 350

Implementation: public val detectFrameSize: Int = DEFAULT_MIN_DETECT_FRAME_SIZE

Frame edges offset#

The estimation calculates the distance from the detected face's bounding box to the edges of the image.

Minimal border distance:

  • Without OneShotLiveness estimation: The minimal border distance for best shot estimation is 0 pixels. This means the face can be right at the edge of the frame.
  • With OneShotLiveness estimation: The minimal border distance increases to 10 pixels to ensure sufficient space around the face for accurate OneShotLiveness estimation.

The default value is set to 0 pixels.

Implementation: public val borderDistance: Int = DEFAULT_BORDER_DISTANCE

Eye state#

The estimation determines whether the eyes in a detected face are open or closed.

The estimation is performed only if eye interaction is enabled.

Face occlusion#

The estimation determines whether the lower part of the face in the frame is occluded by an object. This feature allows you to define whether such frames can still be considered as best shots.

You can enable or disable the estimation via the LunaConfig.acceptOccludedFaces parameter. By default, this parameter is set to true, meaning that no estimations for occluded faces are performed.

val config = LunaConfig.create(
                ...
                acceptOccludedFaces = true
                ...
            )

When acceptOccludedFaces = false, LUNA ID POS checks for occlusions of the nose, mouth, and lower part of the face. If an occlusion is detected, it triggers the OccludedFace error.

If acceptOccludedFaces or acceptMask are set to true, LUNA ID POS skips the corresponding estimations for face occlusions or medical masks, respectively.

Implementation: public val acceptOccludedFaces: Boolean = true

Medical mask estimation#

The estimation determines whether the face in a frame is partially covered by a medical mask. This feature allows you to define whether such frames can still be considered as best shots.

If acceptOccludedFaces or acceptMask are set to true, LUNA ID POS skips the corresponding estimations for face occlusions or medical masks, respectively.

By default, acceptMask is set to true, allowing frames with occluded faces to be considered as potential best shots. Adjust this setting based on your specific requirements.

Implementation: public val acceptMask: Boolean = true

Glasses estimation#

The estimation determines whether the eyes in a frame are occluded by glasses.

You can specify detailed rules for eye occlusion:

  • Images of people wearing sunglasses cannot be considered best shots.
  • Images of people wearing eyeglasses cannot be considered best shots.
  • Images of people wearing any type of glasses cannot be considered best shots.

For details, see Getting the best shot with faces with occluded eyes.