Skip to content

IadCameraController

This page documents the IadCameraController class in detail. It is the primary object used in external applications and the core functionality of the Android Capture Library.

Constructors

You can initialize the class in various ways depending on your needs.

Without Preview

If you don't want to display a preview to the user, you can use the following constructors.

IadCameraController(
    faceDetector: AutocaptureFaceDetector<Jpeg, *>,
    context: Context,
    lifecycleOwner: LifecycleOwner
)

In case if you don't need the face recognition feature.

IadCameraController(
    context: Context,
    lifecycleOwner: LifecycleOwner
)

With preview

When you want to show a preview to the user, you can use the following constructors.

IadCameraController(
    faceDetector: AutocaptureFaceDetector<Jpeg, *>,
    previewView: PreviewView,
    lifecycleOwner: LifecycleOwner,
)

If you don't need the face recognition feature:

IadCameraController(
    previewView: PreviewView,
    lifecycleOwner: LifecycleOwner
)

Properties

Variable name Type Default value Description
isAutocaptureEnabled Boolean True Returns true if autocapture is enabled, false otherwise. When a user sets the value to true or false, autocapture is enabled or disabled accordingly

Methods

Method name Description
startDetection() Initiates the process of automatic face detection
openCamera() Opens the device's front camera
closeCamera() Closes the device's front camera
startPreview() Initiates image streaming preview to the PreviewView
stopPreview() Stops image streaming preview to the PreviewView
takePhoto() Takes a photo immediately after calling this method without checking for faces in the picture
close() Frees the cameraController instance's resources

Listeners/Processors

onCameraErrorListener

The onCameraErrorListener designed to listen for any errors that may occur with the camera:

cameraController.onCameraErrorListener = OnCameraErrorListener { error ->
    // Error processing
}

photoProcessor

This event is triggered when a photograph is being processed. It allows you to use the photograph that has been taken, which can be useful for showing a preview of the photograph taken. For example:

cameraController.photoProcessor = object : ImageProcessor {
    override fun process(data: ByteArray, size: Size, format: Int, rotationAngle: Int) {
        // Processing...
    }
}

bundleProcessor

Event that triggers after a photograph has been taken and processed. The output value is ready to be sent as payload to the server. Example:

cameraController.bundleProcessor = object : BundleProcessor {
    override fun process(bundle: ByteArray) {
        // Finished processing, "bundle" is ready to be sent to IDLiveFace Plus server
    }
}

detectionResultProcessor

onDetectionErrorListener is an event listener that forwards face detector exceptions:

cameraController.onDetectionErrorListener = OnDetectionErrorListener { exception ->
    // Handle the excpetion.
}

The LocalFaceDetector provides a DetectionShortDescription output which will adopt the following values according to the current status of the image that has been taken:

Status Description
Ok The photograph is fine.
TooManyFaces There is more than one face in the picture.
FaceNotFound No face is found in the camera-taken image.
FaceTooSmall The face is too far away from the camera or occupies a small area of the image.
FaceCropped The face is only partially visible.
FaceAngled The face has too big of an angle relative to the camera's view angle.
FaceOccluded The face is covered or not fully visible (face masks will trigger this).
FaceTooClose A face is too close to the camera.
FaceCloseToBorder A face is too close to the image border.
FaceMoving A face is in motion.
Undefined We can't make any statements about the face because we don't have enough information.

frameProcessor

This event allows you to process a frame stream from the camera:

cameraController.frameProcessor = object : FrameProcessor {
    override fun process(imageProxy: ImageProxy) {
        // Handle the frame.
    }
}