Liveness Detection Android SDK
Face Liveness Detction Android SDK
Code
Setup
Copy the SDK (
libfacesdk
folder) to theroot
folder in your project.Add SDK to the project in
settings.gradle
rootProject.name = "YourProjectName"
include ':app'
include ':libfacesdk'
Add dependency to your
build.gradle
implementation project(path: ':libfacesdk')
APIs
setActivation: This API is used to activate the SDK
public static native int setActivation(String var0);
Input
var0 (String): The license string
Return value
The SDK activation status code.
0: Success
Non-zero: Activation failed
init: This API is used to initialize the SDK
public static native int init(AssetManager var0);
Input
var0 (AssetManager): An instance of AssetManager used to access application assets
Return value
The SDK initialization status code.
0: Success
-1: License Key Error
-2: License AppID Error
-3: License Expired
-4: Activate Error
-5: Initialize SDK Error
faceDetection: This API is used to detect faces and determine if the faces are real or fake
public static native List<FaceBox> faceDetection(Bitmap var0, FaceDetectionParam var1);
Input
var0 (Bitmap): The Bitmap image
var1 (FaceDetectionParam): Parameters for face detection
Return value
A list of FaceBox objects representing the detected faces and their liveness scores.
FaceDetectionParam
public class FaceDetectionParam {
public boolean check_liveness = true; //set it to True to check liveness
public int check_liveness_level = 0; // 0: accurate model, 1: light model
}
FaceBox
public class FaceBox {
public int x1;
public int y1;
public int x2;
public int y2;
public float liveness;
public float yaw;
public float roll;
public float pitch;
}
The liveness score ranges from 0.0 to 1.0
If it's greater than the threshold, it's real face
Last updated