Selphi Component
1. Introductionβ
The Component addressed in the current document is called the Selphi Component. This is responsible for capturing a selfie of the user and the subsequent extraction of the most important facial characteristics. Its main functionalities are the following:
- Internal camera management.
- Permissions management.
- Assists the processes of capturing the user's face.
- Generation of templates with the facial characteristics and the image of the user's face for the Liveness detection process
1.1 Minimum requirementsβ
- If the Injection Attack Detection (IAD) feature is used, then: API level 24 RAM: 3 GB
1.2 Plugin versionβ
The current plugin version can be checked as follows:
- Look for the pubspec.yaml file at the root of the plugin.
- The KEY/TAG version indicates the version.
2. Component integrationβ
βΉοΈ Before integrating this component, it is recommended to read the documentation related to Core Component and follow the instructions indicated in said document.
This section will explain step by step how to integrate the current component into an existing project.
β οΈ For this section, the following values ββwill be considered:
- <%APPLICATION_PATH%> - Path to the root of the application (example: /folder/example)
- <%PLUGIN_CORE_PATH%> - Path to the root of the Core plugin, which is required (example:/folder/sdk-core)
- <%PLUGIN_SELPHI_FACE_PATH%> - Path to the root of the current plugin (example /folder/sdk-selphi)
2.1. Plugin installation: Commonβ
The plugin allows execution on Android and iOS platforms. This section explains the common steps to all platforms. To install the plugin, the following steps must be adopted:
- Make sure Flutter is installed.
- Access APPLICATION_PATH at a terminal and run:
dart pub token add "https://facephicorp.jfrog.io/artifactory/api/pub/pub-pro-fphi"
- Access to <%APPLICATION_PATH%> folder, and in the pubspec.yaml file add:
fphi_sdkmobile_selphi:
hosted:
name: fphi_sdkmobile_selphi
url: https://facephicorp.jfrog.io/artifactory/api/pub/pub-pro-fphi/
version: ^2.6.0
(Only if you use Selphi IAD)
fphi_sdkmobile_selphi_iad:
hosted:
name: fphi_sdkmobile_selphi_iad
url: https://facephicorp.jfrog.io/artifactory/api/pub/pub-pro-fphi/
version: ^2.6.0
2.2 Plugin installation: iOSβ
2.2.1 Project configurationβ
For the iOS version, when adding our plugin to the final application, the following points must be previously taken into account:
- Add camera permissions: To use the widget, you need to enable the camera permission in the application's info.plist file (included within the project in the ios folder). You will need to edit the file with a text editor and add the following key/value pair:
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses the camera</string>
2.2.2 Update the Podfileβ
In the project podfile it will be necessary to add the information from the private repository (see section 2.1). To do this, the following lines must be added at the beginning of the file:
platform :ios, '13.0' //MIN VERSION
plugin 'cocoapods-art', :sources => ['cocoa-pro-fphi']
source 'https://cdn.cocoapods.org/'
β οΈ To know more about the configuration and use of Cocoapods Artifactory, it is necessary to access the following document of Core Component.
2.2.3 Possible issuesβ
If environment problems occur or the plugin is not updated after making new changes (for example, problems occurred due to the bundle not being generated correctly, or the libraries not being updated to the correct versions), it is recommended to execute the following sequence of instructions after launching the plugin:
Open the application's ios folder at a terminal.
Run the following command:
pod deintegrate
- Remove the Podfile.lock
- Run the following command (or open the project with Xcode and run it):
pod install --repo-update
y
pod repo-art update cocoa-pro-fphi
2.3 Plugin installation: Androidβ
2.3.0 Set Android SDK versionβ
For Android, the minimum SDK version required by our native libraries is 24, so if your app has a Minimum SDK defined less than this, it will need to be modified to avoid a compile error. To do this, access the application's build.gradle file (located in the android folder) and modify the following parameter:
buildscript {
ext {
minSdkVersion = 24
}
}
3. Component configurationβ
The actual component contains a number of Dart methods and interfaces contained within the SelphiFaceConfiguration file. In this file you can find the necessary API for the communication between the application and the native functionality of the component. It is then explained what each one of those listed is for and the other properties that affect the operation of the component.
Below is the SelphiFaceConfiguration class, which allows you to configure the Selphi component:
class SelphiFaceConfiguration {
bool mDebug;
bool mFullscreen;
bool mLogImages;
bool mStabilizationMode;
bool mTemplateRawOptimized;
bool mEnableGenerateTemplateRaw;
bool mQRMode;
bool mShowResultAfterCapture;
double mCropPercent;
double mJPGQuality;
SelphiCompressFormat mCompressFormat;
String mTranslationsContent;
String mViewsContent;
int? mCameraId;
dynamic mParams;
SelphiFaceLivenessMode mLivenessMode;
bool? mShowDiagnostic;
bool? mShowTutorial;
bool? mShowPreviousTip;
SelphiFaceExtractionDuration? mExtractionDuration;
SelphiCamera mCameraPreferred;
String? license;
}
βΉοΈ All the configuration can be found in the component's SelphiFaceConfiguration class.
When making the call to the widget there is a series of parameters that must be included. They will be briefly discussed below.
3.1. resourcesPathβ
type: string
Sets the name of the resource file that the widget will use for its graphical configuration. This file is customisable and is located in the plugin in the src/main/assets folder for Android and in the ios/Frameworks and Resources folder for iOS. Its installation is transparent to the user, it will simply be added to the respective platform's projects during plugin installation. More details about how this resource pack works and how to modify it are explained in section 6.
resourcesPath: "fphi-selphi-widget-resources-sdk.zip",
3.2. cropβ
type: boolean
Indicates whether the images returned (in the images parameter that is activated with logImages = true) in the completion event contain only the area of ββthe detected face, at a magnification given by CropPercent, or whether the entire image is returned.
crop: false
3.3. cropPercentβ
type: float
Specifies the magnification percentage of the detected face area to compose the returned image.
cropPercent: 1.0
3.4. debugβ
type: boolean
Sets the debugging mode of the widget.
debug: false
3.5. livenessModeβ
type: SelphiFaceLivenessMode
Sets the liveness mode of the component. The possible values are:
- NoneMode: Indicates that the photodetection mode should not be enabled in authentication processes.
- PassiveMode: Indicates that the passive life test is carried out on the server, sending the corresponding "BestImage" for this purpose
- MoveMode: Indicates that the liveness test is active by displaying instructions during the capture, and returning the corresponding result of the process.
livenessMode: SdkSelphiEnums.SdkLivenessMode.PassiveMode
3.6. stabilizationModeβ
type: boolean
Property that allows activating or deactivating the stabilised mode before the face detection process. In the case of being activated, it will give some guidelines to know if it is correctly located or not.
stabilizationMode: true
3.8. fullScreenβ
type: string
Sets whether you want the sdk to start in full screen mode, hiding the status bar.
fullscreen: true
3.9. logImagesβ
type: boolean
Indicates whether the sdk returns to the application the images used during extraction or not. It should be noted that returning images can result in a significant increase in device resource usage:
logImages: false
3.10. templateRawOptimizedβ
type: boolean
Indicates whether if the selfie token generated must be optimized or not.
templateRawOptimized: false
3.11. showDiagnosticβ
type: boolean
Shows a pop-up with the component diagnostic if the process fails.
showDiagnostic: true
3.12 enableGenerateTemplateRawβ
type: boolean
Optional parameter. Only visible if the parameter enableGenerateTemplateRaw is set to true. The widget will return the bestImage encrypted and in stringBase64 format.
enableGenerateTemplateRaw: true
3.13 showResultAfterCaptureβ
type: boolean
Indicates whether or not to display a screen with the captured image of the selfie after the process. This screen gives the user the option of repeating the capture process if the image obtained is not correct.
showResultAfterCapture: false
3.14 showTutorialβ
type: boolean
Indicates whether or not to display the tutorial before the process. After the tutorial finishes, the component process will continue as usual.
showTutorial: true
3.15 compressFormatβ
type: boolean
Indicates the image format compression. The possible values are:
- SelphiCompressFormat.T_PNG
- SelphiCompressFormat.T_JPEG
compressFormat: SelphiCompressFormat.T_JPEG;
3.16 videoFilenameβ
type: string
β οΈ This is an advanced property, and in most use cases you don't need to modify it. Incorrect use may cause component malfunction.
Sets the absolute path of the file name in which a video of the capture process will be recorded. The application is responsible for requesting the necessary permissions to the phone in case that route requires additional permissions. The component, by default, will not perform any write processing unless a file path is specified using this method.
videoFilename: β\<videofile-path\>β;
3.17 translationsContentβ
type: string
β οΈ This is an advanced property, and in most use cases you don't need to modify it. Incorrect use may cause component malfunction.
This property allows, through a string in xml format, to configure the current location of the widget. The definition of this model can be found, by default, in an internal translations folder within the resources .zip. This property allows an application to update and replace the current location of the component at run time.
translationsContent: β\<translation-content-string\>