Optional quality checks ¶
Supported optional checks¶
- EyesClosed
- DarkImage
- FaceBlurry
- MouthOpen
- SunglassesDetected
- FaceNotCentered
You can enable an optional quality check by using FaceDetectorOptions:
val optionalChecks = listOf(OptionalCheck.FaceNotCentered, OptionalCheck.SunglassesDetected)
val faceDetectorOptions = FaceDetectorOptions.createFaceDetectorOptions(optionalChecks)
val faceDetector = LocalFaceDetector(context, faceDetectorOptions)
The optional check result will be returned in OnDetectionResultListener:
faceDetector.onDetectionResultListener = OnDetectionResultListener { result ->
    val optionalCheck = result.optionalCheck
    val shortDescription = result.shortDescription
    val hint = if (optionalCheck != null) {
        optionalCheck.name
    } else {
        shortDescription.name
    }
    faceDetectionHint.postValue(hint)
}
Important!
OptionalCheckandDetectionShortDescriptionare independent checks. It means ifDetectionShortDescriptionequalsOk, anOptionalCheckmay still be present in the detection result.
Expected handling of the detection result is to process OptionalCheck first, and if OptionalCheck is null, then process DetectionShortDescription.
Deprecated optional checks¶
Before 2.3.0, FaceNotCentered should be enabled by using the following code snippet:
val faceDetectorOptions = FaceDetectorOptions.createFaceDetectorOptions(true)
val faceDetector = LocalFaceDetector(context, faceDetectorOptions)
It was processed as an enum value of DetectionShortDescription in OnDetectionResultListener. Since 2.3.0, this approach is still functional but is considered deprecated and should be replaced by the approach described above.