Skip to content

Error processing#

DetectionError#

Types of detection errors:

Error Description
PrimaryFaceLostCritical Critical loss of the primary face.
PrimaryFaceLost Loss of the primary face.
FaceLost Face lost.
TooManyFaces Too many faces.
FaceOutOfFrame The face went outside the frame.
FaceDetectSmall Face is too small.
BadHeadPose Bad head pose.
BadQuality Poor image quality.
BlurredFace Blurred face.
TooDark Too dark.
TooMuchLight Too much light.
GlassesOn Glasses detected.
OccludedFace The face is partially closed.
BadEyesStatus Bad eye status.
FaceWithMask Mask detected.

Processing example#

lifecycleScope.launch {
    LunaID.errorFlow.collect { error ->
        error?.let {
            val message = when (it.error) {
                DetectionError.FaceLost -> "Face not found"
                DetectionError.PrimaryFaceLost -> "The primary face is lost"
                DetectionError.PrimaryFaceLostCritical -> "Critical face loss"
                DetectionError.FaceDetectSmall -> "Move closer to the camera"
                DetectionError.FaceOutOfFrame -> "Keep your face in the center of the frame"
                DetectionError.BadHeadPose -> "Keep your head straight"
                DetectionError.BadEyesStatus -> "Open your eyes"
                DetectionError.TooDark -> "Too dark"
                DetectionError.TooMuchLight -> "Too much light"
                DetectionError.BlurredFace -> "Keep your device still"
                DetectionError.OccludedFace -> "Take your hand away from your face"
                DetectionError.GlassesOn -> "Take off your glasses"
                DetectionError.FaceWithMask -> "Take off your mask"
                DetectionError.TooManyFaces -> "There must be one person in the frame"
                DetectionError.BadQuality -> "Poor image quality"
                else -> "Detection error"
            }
            // Show message to a user
        }
    }
}

Important notes#

  1. Always check the initialization status before using the SDK.
  2. Handle all possible errors.
  3. Free up resources when shutting down the SDK.
  4. Use appropriate permissions in AndroidManifest.xml:
    • android.permission.CAMERA
    • android.permission.INTERNET (for working with the API)