Skip to main content

Configuration

The face capture consists of two components:

  • MIDFaceView: the camera view. It shows the preview, the detection area and the guidance messages.
  • MIDFaceSDK: the face engine. It detects the face, applies liveness and runs the biometric operation.

Initialisation​

Initialise the SDK before using any other component, with the application ID, a token issued by your backend and the full server URL:

MIDSDK.shared.doInitSDK(applicationId: "YOUR_APPLICATION_ID",
authToken: authToken,
serverUrl: "https://{SERVER-URL}/api/v7")
Include the API version in the URL

Since version 7.0.2, the SDK no longer appends the API version. serverUrl must contain the complete host and path.

The token is valid for 30 minutes. Request it right before the user reaches the capture screen, so that it remains valid during the operation.

Camera view​

Build MIDFaceView with the frame it will occupy and add it to your view hierarchy:

let builder = MIDFaceViewBuilder()
builder.set(frame: frame)
let faceView = try builder.build()

The view guides the user in real time to place the face inside the detection area, at the right distance and with suitable lighting. Since version 7.2.1, it also warns about non-frontal faces, sunglasses and faces outside the detection area.

Face engine​

Build MIDFaceSDK with MIDFaceSDKBuilder and attach it to the view:

OptionDescription
targetViewThe MIDFaceView that hosts the camera.
addFeedbackListenerReceives the guidance events. Pass MIDFaceView to display them.
livenessDetectionModeLiveness method applied to the capture. See Liveness.
addLivenessListenerReceives the progress of the liveness check. Pass MIDFaceView to display it. Only applies when a liveness method is set.

Liveness modes​

Liveness is configured once in the engine and applies to every operation it runs.

MIDFaceLivenessDetectionModeTypeUser interaction
headPassiveImagePassive, on one image. RecommendedThe user looks at the camera
headPassiveVideoPassive, on a short videoThe user looks at the camera for a few seconds
headMovementActiveThe user moves the head when prompted
noneNo livenessFace comparison only. Not suitable for authentication

Keep liveness enabled in every operation, including enrolment. Without it, a photo of another person could be enrolled or verified. See Attack detection.

let builder = MIDFaceSDKBuilder()
builder.targetView(faceView)
builder.addFeedbackListener(faceView)
if livenessMode != .none {
builder.addLivenessListener(faceView)
builder.livenessDetectionMode(livenessMode)
}
let faceSDK = builder.build()

Run an operation​

faceSDK.start(recognitionMode: recognitionMode, parameters: parameters, operationListener: listener)
MIDRecognitionModeParametersListenerGuide
.enrollmentMIDEnrollmentParameters(userId:)MIDEnrollmentListenerEnrolment
.verificationMIDVerificationParameters(userId:)MIDVerificationListenerVerification
.identificationMIDIdentificationParameters(groupId:)MIDIdentificationListenerIdentification

In Objective-C, the classes and protocols use the CMID prefix: CMIDRecognitionMode, CMIDVerificationParameters, CMIDVerificationListener and so on.