Action Liveness
1.Product Description
1.1 Introduction
The function of action detection is to separate the real face from the face in picture, and automatically determine whether the face in the screen is a real face, effectively preventing the fake human face.
1.2 Process Flow
1.3 Anti-hack Flow
Mobile SDK
: You should integrate it in your Android application first, this will help you to capture face image.Server API(Anti-hack)
: It will help to check whether the face in uploaded encrypt buffer is real face or not, Server API Doc . In Action liveness SDK, we have implemented this API.
1.4 The Current Version
Support cpu structures: armeabi-v7a,arm64-v8a.
SDK dual architecture compilation increments is 5.3M, and armeabi-v7a compilation increments 4.7M, arm64-v8a compilation increments 4.8M.
The minimum support system version Android4.2.
2.Quick Integration Guide
2.1 Note
License file (DFLicense) is used to control the package name and valid time of the program (the time range can be obtained by directly viewing the content of the file). Please make sure that the package name of the program is the same as the package name bound to the license.
2.2 Quick Integration
We supply two different integration modes for you to integrate liveness into your application.
2.2.1 Integration with maven
Open any Android project and add the following maven repository configuration to the project's build.gradle.
maven { url 'https://maven.accuauth.com/repository/maven-releases/' // If your gradle version is greater than 7.0, you need to add the following configuration to allow pulling aar via http allowInsecureProtocol = true }
Add library dependencies to the project's app module build.gradle.
implementation 'com.dfsdk.liveness:df-liveness-action-sdk:2.2.6@aar' implementation 'com.liveness.dflivenesslibrary:df-liveness-action-ui:2.2.7@aar'
- Add DFLicense file to your project's assets directory.
2.2.2 Integration with library module
Please follow below steps to integrate silent liveness into your app.</br>
SDK Directory Structure
Quick Integration
Before you use the SDK, you need to integrate it into your development environment first.
Import DFLivenessActionDemo's DFLivenessLibrary module to your project by File->New->importModule->Select the DFLivenessLibrary in DFLivenessActionDemo folder->Continuously click Next to complete the import.
Add the following code to the build.gradle in your application.
repositories { flatDir { dirs project(':DFLivenessLibrary').file('libs') } }
Add following code to the dependencies{} section of build.gradle.
compile project(':DFLivenessLibrary')
For example:
allprojects { repositories { google() jcenter() flatDir { dirs project(':DFLivenessLibrary').file('libs') } } } dependencies { compile project('DFLivenessLibrary') }
Add DFLicense file to your project's assets directory.
2.3 Start Detection
Make sure your own Appliction class to implement DFTransferResultInterface interface
If you do not have your own Application class, please customize it.
public class MyApplication extends Application implements DFTransferResultInterface {
private DFProductResult mResult;
@Override
public void setResult(DFProductResult result) {
mResult = result;
}
@Override
public DFProductResult getResult() {
return mResult;
}
}
Launch detection
Bundle bundle = new Bundle();
// OUTPUT_TYPE config, The type of outputType passed in must be multiImg
bundle.putString(DFActionLivenessActivity.OUTTYPE,Constants.MULTIIMG);
//EXTRA\_MOTION\_SEQUENCE Action detection sequence configuration,supports five detection actions, STILL, BLINK, MOUTH, NOD, YAW, The actions are separated by Spaces。 The first action must be STILL。Default configuration is "STILL BLINK MOUTH NOD YAW"
//Notice that there are at least two actions, one of them is STILL
bundle.putString(DFActionLivenessActivity.EXTRA_MOTION_SEQUENCE, "STILL BLINK MOUTH NOD YAW");
Intent intent = new Intent();
intent.setClass(this, DFActionLivenessActivity.class);
intent.putExtras(bundle);
//enable to get image result
intent.putExtra(DFActionLivenessActivity.KEY_DETECT_IMAGE_RESULT, true);
startActivityForResult(intent, KEY_TO_DETECT_REQUEST_CODE);
Use onActivityResult to receive data
Get SDK result by onActivityResult(int requestCode, int resultCode, Intent data) function.
if resultCode == Activity.RESULT_OK, the liveness detect success, otherwise liveness detect fail.
if (resultCode == RESULT_OK) {
DFProductResult mResult = ((DFTransferResultInterface) getActivity().getApplication()).getResult();
///Get images
DFLivenessSDK.DFLivenessImageResult[] imageResultArr = mResult.getLivenessImageResults();
if (imageResultArr != null) {
int size = imageResultArr.length;
if (size > 0) {
DFLivenessSDK.DFLivenessImageResult imageResult = imageResultArr[0];
Bitmap imageBitmap = BitmapFactory.decodeByteArray(imageResult.image, 0, imageResult.image.length);
}
}
// the encrypt buffer which is used to send to anti-hack API
byte[] livenessEncryptResult = mResult.getLivenessEncryptResult()
} else {
if (data != null) {
int errorCode = data.getIntExtra(DFActionLivenessActivity.KEY_RESULT_ERROR_CODE, -10000);
Log.e("onActivityResult", "action liveness cancel,error code:" + errorCode);
}
}
When liveness detect fail, the error code(errorCode) refers to the error code
2.4 AndroidX Migration
The gradle plug-in version of build.gradle in the application should be no less than 3.2
classpath 'com.android.tools.build:gradle:3.2.0'
compileSdkVersion
and targetSdkVersion
are not less than 28
compileSdkVersion 28
defaultConfig {
targetSdkVersion 28
}
AS 3.2 or above version provides a much faster and easier way to migrate to AndroidX with one click.Select ReFactor on the menu - Migrate to AndroidX...
DFLivenessBaseActivity