Configure Face module
This section explains how to configure and use the MobbID Face module.
MIDFaceView
to your views or composables
Step 1: Add You will need to use the MIDFaceView
class in your project. This class is used to manage feedback messages during facial detection as well as to serve as the host for the camera surface.
If you are using traditional Android views (XML layout):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mobbeel.mobbid.face.ux.MIDFaceView
android:id="@+id/face_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
If you are using Jetpack Compose:
AndroidView(
factory = { midFaceView },
modifier = Modifier.fillMaxSize(),
)
MIDFaceView
:
Step 2: Configure You must invoke the initView(initListener: (() -> Unit?)?)
method to properly initialize the class. Optionally, you can pass a listener that will be called upon completion of the initialization.
midFaceView.post {
midFaceView.initView{
// TODO: MIDFaceView has been initialized
}
}
MIDFaceSDK
:
Step 3: Configure val faceSDK = MIDFaceSDKBuilder().interactiveMode().apply {
defaultCameraMode(MIDFaceCameraMode.FRONT)
targetView(midFaceView.findViewById(com.mobbeel.mobbid.face.ux.R.id.camera_container))
setDetectionBox(midFaceView.detectionBox)
addFeedbackListener(midFaceView)
}.build()
If your use case requires performing a liveness verification, you can configure it at this step:
val faceSDK = MIDFaceSDKBuilder().interactiveMode().apply {
defaultCameraMode(MIDFaceCameraMode.FRONT)
targetView(midFaceView.findViewById(com.mobbeel.mobbid.face.ux.R.id.camera_container))
setDetectionBox(midFaceView.detectionBox)
addFeedbackListener(midFaceView)
if (isPerformLivenessEnabled) {
livenessDetectionMode(MIDFaceLivenessDetectionMode.HEAD_PASSIVE_IMAGE)
addLivenessListener(midFaceView)
}
}.build()
Step 4: Start a face biometric method:
You can now start using the facial biometric method of your choice. You will need to configure a set of parameters and callbacks specific to each method.
faceSDK.start(
recognitionMode = recognitionMode,
parameters = recognitionParameters,
operationListener = callback,
)
You will find more detailed information on how to use the faceSDK.start(...)
method, as well as the parameters associated with each method, in the code examples section.