2 User Guide

2.1 SDK directory structure

2.2 Development environment

Before using the SDK, the SDK first needs to be integrated into the development environment. The development environment of the project requires to be Xcode 7.0 or later, and the operating environment requires iOS7.0 or later.

The detailed operational requirement is described below.

2.2.1 Development environment configuration

Import the SDK package.

Drag the libSTSilentLivenessController folder into the project, note that the copy option is checked, and click Finish button.

This SDK does not support CocoaPods.

Import the license file.

For details, please refer to License introduction.

2.2.2 Compile option settings

Xcode linker parameters must be added: -ObjC and -lc++.

After adding the -ObjC parameter, the linker can load all Objective-C classes and categories in the static library into the final executable file.

The -lc++ parameter is added because the static library requires c++ standard library support.

How to add:

Add -lc++ and -ObjC to TARGETS > Build Settings > Linking > Other Linker Flags.

If the development tool used is Xcode 7.0 or a later version, Bitcode needs to be closed manually.

Steps:

Set to NO to TARGETS > BuildSettings > Enable Bitcode.

2.2.3 Camera access permission settings

When debugging systems on iOS 10 or later using Xcode 8 or later, camera access permission needs to be added in the info.plist file when calling the camera function.

<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string

2.3 Interface call flow

The interface call of the silent liveness detection SDK is mainly for the STSilentLivenessController. The following is a detailed introduction.

2.3.1 Interface call flow chart

1. Comply with STSilentLivenessDetectorDelegate protocol and STSilentLivenessControllerDelegate protocol.

@interface ViewController () <STSilentLivenessDetectorDelegate,STSilentLivenessControllerDelegate>

2. Initialize the view controller for silent liveness detection.

STSilentLivenessController *livenessVC = [[STSilentLivenessController alloc] initWithSetDelegate:self];

3. Set optional conditions for silent liveness detection

Set the liveness detection timeout time, pass conditions, hack threshold, occlusion, illumination conditions, blurriness, and eye open filtering conditions. The SDK performs silent liveness detection according to your settings.

Parameter

Description

setDetectTimeout

Timeout time

setPassConditionMinDuration

Minimum time needed to pass the detection

setPassConditionMinFrames

Minimum frames needed to pass the detection

FaceDistanceRateWithFarRate

Maximum distance to the face

FaceDistanceRateWithCloseRate

Minimum distance to the face

setHackThreshold

Hack (Spoofing) threshold

setIlluminationFilterEnable

Enable/disable illumination detection

setBlurryFilterEnable

Enable/disable blurriness detection

setEyeOpenFilterEnable

Enable/disable eye open detection

setOcclusionEnable

Enable/disable occlusion of face parts detection

//Set timeout time
[_detector setDetectTimeout:kSenseIdSilentLivenessDefaultTimeOutDuration];
//Set pass conditions
[_detector setPassConditionMinDuration:0 minFrames:4];
//Set distance conditions
[_detector setFaceDistanceRateWithFarRate:0.4 closeRate:0.8];
//Set hack threshold
[_detector setHackThreshold:kSenseIdSilentLivenessDefaultHackThreshold];
//Set illumination filter
[_detector setIlluminationFilterEnable:YES
                    darkLightThreshold:kSenseIdSilentLivenessDefaultDarkLightThreshold
                  strongLightThreshold:kSenseIdSilentLivenessDefaultStrongLightThreshold];
//Set blurriness filter
[_detector setBlurryFilterEnable:YES threshold:kSenseIdSilentLivenessDefaultBlurThreshold];
//Set eye open filter
[_detector setEyeOpenFilterEnable:YES threshold:kSenseIdSilentLivenessDefaultEyeOpenThreshold];
//Set face occlusion filter
[_detector setOcclusionEnable:YES];

4. Pop out the view controller with navigation bar.

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.livenessVC];

[self presentViewController:nav animated:YES completion:nil];

5. Implement the callback method in STSilentLivenessDetectorDelegate.

/**
 *  Callback for successful liveness detection
 *
 *  @param protobufData         Return encrypted binary data
 *  @param images             Returns the STSilentImage array according to the specified output scheme. Refer to STSilentImage.h for STSilentImage properties.
 *  @param faceRects          Returns the STSilentRect array according to the specified output scheme. Refer to STSilentRect.h for STSilentRect properties.
 */
- (void)silentLivenessSuccessWithProtobufData:(NSData *)protobufData
                                       images:(NSArray *)images
                                    faceRects:(NSArray *)faceRects{
}

/**
 *  Callback for liveness detection failure
 *
 *  @param livenessResult      Running result STIDSilentLivenessResult
 *  @param protobufData        Return encrypted binary data
 *  @param images            Returns the STSilentImage array according to the specified output scheme. Refer to STSilentImage.h for STSilentImage properties.
 *  @param faceRects         Returns the STSilentRect array according to the specified output scheme. Refer to STSilentRect.h for STSilentRect properties.
 */
- (void)silentLivenessFailureWithErrorCode:(STIDSilentLivenessResult)livenessResult
                              protobufData:(NSData *)protobufData
                                    images:(NSArray *)images
                                 faceRects:(NSArray *)faceRects{
}

6. Implement the callback method in STSilentLivenessControllerDelegate.

// Callback for device error type
-(void) silentLivenessControllerDeveiceError: (STIDSilentLivenessDeveiceError) deveiceError
{
}
// Cancel detection
-(void) cancelDetect
{
}

2.3.2 Call server interface for face comparison

After successful liveness detection, the SDK will return the corresponding face image and an encrypted binary file. The returned value can be used as a parameter of the public cloud interface for face comparison.

Please refer to the server interface documentation for the specific description of the server interface.

2.4 Interface customization

The silent liveness SDK provides different degrees of customization. You can choose to customize the UI as needed. This section of the document will explain in detail.

Table: Customization options

Customization option

Customization content

Specific introduction

No customization

No customized content

Direct use of the liveness detection SDK

For integration steps, please refer to: Interface call flow

Partial customization

Modify the basic elements of the interface, including:

View Layout

Modify pictures, text, buttons, background color, etc.

Add or hide other interface elements

1. Integrate the standard silent liveness SDK 2. Modify or replace resource files as follows: 1) //Modify the interface layout, picture elements, prompt text:- (void)setupUI 2)//Modify the image resource path: libSTSilentLivenessController/st_silent_liveness_resource.bundle/ images

Full customization

UI redesign

1 Integrate standard silent liveness SDK 2 Rewrite the STSilentLivenessView class

Last updated