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.NONE
SelphiFaceLivenessMode.PASSIVE
SelphiFaceLivenessMode.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:
- ACTIVITY_RESULT_ERROR: The result of the activity is incorrect.
- ACTIVITY_RESULT_MSG_ERROR: The result of the activity received in the msg is incorrect.
- APPLICATION_CONTEXT_ERROR: The required application context is null.
- BAD_EXTRACTOR_CONFIGURATION_ERROR: Widget: Incorrect extractor configuration.
- CAMERA_PERMISSION_DENIED: User has rejected permissions.
- CANCEL_BY_USER: The user has cancelled the process.
- CANCEL_LAUNCH: A general cancellation of the SDK has been done.
- COMPONENT_LICENSE_ERROR: The component license is not correct.
- CONTROL_NOT_INITIALIZATED_ERROR: Widget: Initialisation error.
- EMPTY_LICENSE: The license string is empty.
- EXTRACTION_LICENSE_ERROR: Widget: License error.
- FETCH_DATA_ERROR: Error in the collection of the result.
- FLOW_ERROR: Error in the flow process.
- HARDWARE_ERROR: Widget: Hardware error.
- INITIALIZATION_ERROR: Initialisation error.
- MANAGER_NOT_INITIALIZED: Managers are null.
- NO_DATA_ERROR: Input data is null.
- OPERATION_NOT_CREATED: No operation is in progress.
- RESOURCES_NOT_FOUND: Resource zip not found.
- SETTINGS_PERMISSION_ERROR: Widget: Permission error.
- TEMPLATE_ERROR:
- TIMEOUT: Timeout in process.
- UNEXPECTED_CAPTURE_ERROR: Widget: Capture error.
- UNKNOWN_ERROR: Unknown error.
- 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:
NONE
PASSIVE
MOVE
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 |