Facial Capture
1. Introductionβ
Facial capture is performed with the Selphi Component.
This component is responsible for capturing a user selfie and extracting the most important facial features. Its main processes are:
- Internal camera and permission management.
- Guided assistance during the userβs facial capture process.
- Generation of facial templates and the user image.
Refer to the Quickstart section for the basic SDK integration steps. This guide adds information specific to launching this component.
2. Dependencyβ
The component-specific dependency is:
implementation "com.facephi.androidsdk:selphi_component:$version"
3. Available Controllersβ
| Controller | Description |
|---|---|
| SelphiController | Main facial recognition controller |
| RawTemplateController | Controller to generate a RawTemplate from an image |
| SignatureSelphiController | Controller to create a signature file in the platform |
4. Quick Launchβ
Once the SDK is initialized and a new operation has been created, launch the component by using any of its controllers.
Facial capture launch:
val response = SDKController.launch(
SelphiController(
SelphiConfigurationData(...)
)
)
when (response) {
is SdkResult.Error -> Napier.d("Selphi: ERROR - ${response.error.name}")
is SdkResult.Success -> response.data
}
5. Basic Configurationβ
To launch the component, create a SelphiConfigurationData object with the following fields:
SelphiConfigurationData(
resourcesPath = "resources_file.zip",
livenessMode = SelphiFaceLivenessMode.NONE
)
Available livenessMode values:
SelphiFaceLivenessMode.NONESelphiFaceLivenessMode.PASSIVESelphiFaceLivenessMode.MOVE
6. Receiving the Resultβ
The launch returns an SdkResult. Differentiate between success and error:
when (response) {
is SdkResult.Error -> Napier.d("ERROR - ${response.error}")
is SdkResult.Success -> response.data
}
6.1 Handling Errorsβ
Errors are returned as a SelphiError object. Possible values include:
- SPI_ACTIVITY_RESULT_ERROR: The result of the activity is incorrect.
- SPI_ACTIVITY_RESULT_MSG_ERROR: The result of the activity received in the msg is incorrect.
- SPI_APPLICATION_CONTEXT_ERROR: The required application context is null.
- SPI_BAD_EXTRACTOR_CONFIGURATION_ERROR: Widget: Incorrect extractor configuration.
- SPI_CAMERA_PERMISSION_DENIED: User has rejected permissions.
- SPI_CANCEL_BY_USER: The user has cancelled the process.
- SPI_CANCEL_LAUNCH: A general cancellation of the SDK has been done.
- SPI_COMPONENT_LICENSE_ERROR: The component license is not correct.
- SPI_CONTROL_NOT_INITIALIZATED_ERROR: Widget: Initialisation error.
- SPI_EMPTY_LICENSE: The license string is empty.
- SPI_EXTRACTION_LICENSE_ERROR: Widget: License error.
- SPI_FETCH_DATA_ERROR: Error in the collection of the result.
- SPI_FLOW_ERROR: Error in the flow process.
- SPI_HARDWARE_ERROR: Widget: Hardware error.
- SPI_INITIALIZATION_ERROR: Initialisation error.
- SPI_MANAGER_NOT_INITIALIZED: Managers are null.
- SPI_NO_DATA_ERROR: Input data is null.
- SPI_OPERATION_NOT_CREATED: No operation is in progress.
- SPI_RESOURCES_NOT_FOUND: Resource zip not found.
- SPI_SETTINGS_PERMISSION_ERROR: Widget: Permission error.
- SPI_TEMPLATE_ERROR:
- SPI_TIMEOUT: Timeout in process.
- SPI_UNEXPECTED_CAPTURE_ERROR: Widget: Capture error.
- SPI_UNKNOWN_ERROR: Unknown error.
- SPI_WIDGET_RESULT_DATA_ERROR: Error in widget output data.
6.2 Handling Success β dataβ
On success (SdkResult.Success), you receive a SelphiResult object. Images are returned as SdkImage; extract the bitmap via image.bitmap. To convert to Base64:
Base64.encodeToString(this.toByteArray(), Base64.NO_WRAP)
Returned fields in SelphiResult:
6.2.1 templateRawβ
Raw template generated after extraction, valid for matching.
6.2.2 templateβ
Processed template generated after extraction, valid for matching.
6.2.3 bestImageβ
Best full-size image from the authentication process, valid for liveness checks.
6.2.4 bestImageCroppedβ
Cropped image centered on the userβs face, derived from bestImage.
6.2.5 logImagesβ
List of the top 5 captured images (returned if logImages flag is enabled).
6.2.6 bestImageTokenizedβ
Encrypted best image from the liveness process.
7. Advanced Informationβ
This section provides extended details for this component.
7.1 Additional Controllersβ
7.1.1 SignatureSelphiControllerβ
Used like SelphiController but generates a signature file on the platform.
7.1.2 RawTemplateControllerβ
Generates a RawTemplate from a given image (SdkImage).
Example:
val result = SDKController.launch(
RawTemplateController(SdkImage(image))
)
when (result) {
is SdkResult.Error -> Napier.d("GenerateRaw: KO - ${result.error}")
is SdkResult.Success -> result.data
}
7.2 Advanced Component Configurationβ
Create a SelphiConfigurationData object with all available fields:
7.2.0 debugβ
Enables debug mode.
7.2.1 resourcesPathβ
Name of the zip file in assets (ex. resources-selphi-2-0.zip).
7.2.2 cropPercentβ
Percentage to crop around the face; higher values yield a tighter crop.
7.2.3 cropImageDebugβ
Enables debug view for crop percentage.
7.2.4 showResultAfterCaptureβ
Whether to show a screen with the captured image for user review.
7.2.5 showTutorialβ
Enables tutorial screen explaining the capture process.
7.2.6 livenessModeβ
Sets the liveness detection mode:
NONEPASSIVEMOVE
7.2.7 stabilizationModeβ
Requires the user to hold head steady and forward before starting.
7.2.8 cameraFlashEnabledβ
Enables device camera flash.
7.2.9 localeβ
Forces widget to use a specific locale (e.g. en, en_US).
7.2.10 fullscreenβ
Displays the widget full-screen if supported.
7.2.11 templateRawOptimizedβ
Optimizes templateRaw if true.
7.2.12 qrModeβ
Enables QR scanning before authentication.
7.2.13 videoFilenameβ
Absolute path for recording capture video; the app must handle permissions.
7.2.14 viewsContentβ
Custom XML layout string for widget views.
7.2.15 showDiagnosticβ
Shows diagnostic screens at the end.
7.2.16 logImagesβ
Returns top 5 images when enabled.
7.2.17 showPreviousTipβ
Shows a pre-capture tip screen with launch info.
7.2.18 extractionDurationβ
Duration of the facial extraction process.
7.2.19 cameraPreferredβ
Preferred camera (FRONT or BACK).
7.2.20 vibrationEnabledβ
Enables vibration feedback at process end.
7.2.21 moveSuccessfulAttemptsβ
Number of retries for successful MOVE liveness (default 1).
7.2.22 moveFailedAttemptsβ
Number of retries for failed MOVE liveness (default 2).
8. Component Customizationβ
Beyond SDK-wide settings (Advanced Settings), this component allows:
8.1 Textsβ
Override default strings by providing an XML in your app:
<!-- Diagnostic -->
<string name="selphid_component_timeout_title">Time exceeded</string>
<string name="selphid_component_timeout_desc">Check that the document is inside the box and the data is visible.</string>
<string name="selphid_component_internal_error_title">There was a technical problem</string>
<string name="selphid_component_internal_error_desc">We apologize. The capture could not be made</string>
<!-- Previous Tip -->
<string name="selphid_component_tip_message"><b> Focus</b> your document<b> inside the box.</b> The photo will be taken automatically.</string>
<string name="selphid_component_tip_message_alt">Focus your document inside the box. The photo will be taken automatically.</string>
<string name="selphid_component_tip_anim_id_desc">Place your ID card horizontally, and point your phone vertically.</string>
<string name="selphid_component_tip_anim_pass_desc">Place your passport horizontally, and point your phone vertically.</string>
<string name="selphid_component_tip_title">Document photo</string>
<string name="selphid_component_tip_button">Start</string>
<string name="selphid_component_tip_button_alt">Start document capture</string>
<string name="selphid_component_tip_close_button_alt">Back</string>
<string name="selphid_component_tip_info_button_alt">Show advices</string>
<!-- Tutorial -->
<string name="selphid_component_tutorial_message_1">Look for a background with good contrast.</string>
<string name="selphid_component_tutorial_message_2">Place the document in the box</string>
<string name="selphid_component_tutorial_message_3">Avoid glare that makes the document difficult to read.</string>
<string name="selphid_component_tutorial_message_1_anim_id_desc">Place the document on a surface with a different colour than the document.</string>
<string name="selphid_component_tutorial_message_2_anim_id_desc">Place your ID card horizontally, and point your phone vertically.</string>
<string name="selphid_component_tutorial_message_3_anim_id_desc">Reflections appear on the document.</string>
<string name="selphid_component_tutorial_message_1_anim_pass_desc">Place the document on a surface with a different colour than the document.</string>
<string name="selphid_component_tutorial_message_2_anim_pass_desc">Place your passport horizontally, and point your phone vertically.</string>
<string name="selphid_component_tutorial_message_3_anim_pass_desc">Reflections appear on the document.</string>
<string name="selphid_component_tutorial_close_button_alt">Back to previous tutorial</string>
8.2 Animationsβ
Override Lottie animations by placing JSON files in res/raw/:
selphi_anim_prev_tip.json
selphi_anim_prev_tip_move.json
selphi_anim_tuto_m_1.json
selphi_anim_tuto_m_2.json
selphi_anim_tuto_m_3.json
9. Resources Zip Versionsβ
Table of SDK versions and associated resource versions (see Resources section):
| SDK Version | Selphi Resources Version |
|---|---|
| 2.0.2 | 5.13.1 |
| 2.0.3 | 5.13.4 |
| 2.1.0 | 5.14.1 |
| 2.1.1 | 5.14.2 |
| 2.1.2 | 5.15.0 |
| 2.2.0 | 5.16.1 |
| 2.2.1 | 5.16.2 |
| 2.2.2 | 5.16.2 |
| 2.2.3 | 5.17.1 |
| 2.3.1 | 5.17.2 |
| 2.3.2 | 5.17.3 |
| 2.3.3 | 5.17.5 |
| 2.3.4 | 5.17.5 |
| 2.3.5 | 5.17.5 |
| 2.3.6 | 5.18.2 |
| 2.4.0 | 5.19.1 |