3.1 SilentLivenessApi

public final class SilentLivenessApi

public static void init(@NonNull final Context context, @NonNull final String licenseFilePath, @NonNull final String detectionModelFilePath, @NonNull final String alignmentModelFilePath, @NonNull final String qualityModelFilePath, @NonNull final String frameSelectorModelFilePath, @NonNull final String antiSpoofingModelFilePath, @NonNull final OnLivenessListener listener)

Initialization method.

Parameter

Type

Description

context

Context

Application information context

licenseFilePath

String

Storage path of the license file on the device

detectionModelFilePath

String

Storage path of the face detection model file on the device

qualityModelFilePath

String

Storage path of the quality model file on the device

alignmentModelFilePath

String

Storage path of the alignment model file on the device

frameSelectorModelFilePath

String

Storage path of the frame selector model file on the device

antiSpoofingModelFilePath

String

Storage path of anti-spoofing model files on the device

listener

OnLivenessListener

OnLivernessListener (Liveness detection status listener, when set to empty, it cannot be initialized.)

Return value

Description

None

None

public static void setBrowOcclusionEnable(final boolean enable)

Set whether to perform eyebrow occlusion detection during liveness detection, false by default.

Parameter

Type

Description

enable

boolean

Set whether to perform eyebrow occlusion detection during liveness detection, false by default.

Return value

Description

None

None

public static void setBlurryFilterEnable(final boolean enable, final float threshold)

Set whether to perform blurriness detection during liveness detection, false by default. The threshold is 1.4 by default.

Parameter

Type

Description

enable

boolean

Set whether to perform blurriness detection during liveness detection, false by default.

threshold

float

The threshold of blurriness detection between [0, 5], the result score higher than the threshold means blurry.

Return value

Description

None

None

public static void setIlluminationFilterEnable(final boolean enable, final float lowLightThreshold, final float brightThreshold)

Set whether to perform brightness detection during liveness detection, false by default. The low light threshold is 1.899 by default. The bright light threshold is 4.997 by default.

Parameter

Type

Description

enable

boolean

Set whether to perform brightness detection during liveness detection, false by default.

lowLightThreshold

float

The threshold used to judge whether it is too dark. The value range is [0,6]. If the detection result score is smaller than the threshold, it is considered too dark. The default threshold is 1.899. When it is set to 0, it means that the dark brightness detection is turned off.

brightThreshold

float

The threshold used to judge whether it is too bright. The value range is [0,6]. If the detection result score is larger than the threshold, it is considered too bright. The default threshold is 4.997. When it is set to 6, it means that the bright brightness detection is turned off.

Return value

Description

None

None

public static void setEyeOpenThreshold(final float threshold)

Set the threshold used to judge the eye-opening during liveness detection.

Parameter

Type

Description

threshold

float

The threshold used to judge the eye-opening. The value range is [0,1]. If the detection result score is larger than the threshold, it is considered eye-opening. The suggested threshold is 0.47. When it is set to 0, it means that the eye-opening detection is turned off.

Return value

Description

None

None

public static void setOcclusionEnable(final boolean enable)

Set whether to perform occlusion detection during liveness detection, true by default.

Parameter

Type

Description

enable

boolean

Set whether to perform occlusion detection during liveness detection, true by default.

Return value

Description

None

None

public static void setThreshold(final float threshold)

Set the threshold for liveness detection, 0.88 by default.

Parameter

Type

Description

threshold

float

threshold for liveness detection

Return value

Description

None

None

public static void setDetectTimeout(int timeout)

The maximum detection time allowed for each module, the default value is 10s, the unit is in seconds.

Parameter

Type

Description

timeout

int

Set the timeout time in seconds, which is the maximum detection time allowed for each detection. The default timeout time is 10s. If the value is less than 0, STID_E_INVALID_ARGUMENTS error is reported, if it is 0, no timeout is allowed, if it is greater than 0, timeout is set to this value.

Return value

Description

None

None

public static void setFaceDistanceRate(float farRate, float closeRate)

Set the judgment condition for the face distance.

Parameter

Type

Description

farRate

float

The ratio of face height/width to the short edge of the image. The value can be set between [0.0 - 1.0]. The closer the parameter is to 0, the farther the face is away from the screen. The default value is 0.4. When set to 0, there will be no distance prompt.

closeRate

float

The ratio of face height/width to the short edge of the image. The value can be set between [0.0 - 1.0]. The closer the parameter is to 1, the closer the face is to the screen. The default value is 0.8. When set to 0, there will be no distance prompt.

Return value

Description

None

None

public static void inputData(byte[] image, PixelFormat format, Size previewSize, Rect containerRect, boolean frontCameraOrNot, int cameraOrientation)

Liveness detector configuration. Input image for detection.

Parameter

Type

Description

image

byte[]

Image frame data to be detected

format

`PixelFormat

Image frame data type

previewSize

Size

Image size

containerRect

Rect

Preview view size

frontCameraOrNot

boolean

Whether it is a front camera. True is yes, false is no.

cameraOrientation

int

Camera image orientation

Return value

Description

None

None

public static void start()

Ready to start detection. Call before inputData and after init.

Parameter

Description

None

None

Return value

Description

None

None

public static void release()

Release resources after calling init. The resources must be released through release.

Parameter

Description

None

None

Return value

Description

None

None

public static void stop()

Stop the current detection, and reset the detection status. This method is used to retry after failure. If stop is called after init succeeded and before release), detection can be restarted directly by start.

Parameter

Description

None

None

Return value

Description

None

None

public static boolean getBrowOcclusionEnable()

Obtain the setting whether eyebrow occlusion detection switch status. Should be called after init to get the correct result. Otherwise, it will return false, and the correct settings for the eyebrow occlusion cannot be obtained.

Parameter

Description

None

None

Return value

Description

boolean

True indicates eyebrow occlusion detection is turned on, false indicates eyebrow occlusion detection is turned off.

public static boolean getBlurryFilterEnable()

Obtain the setting whether blurriness detection switch status. Should be called after init to get the correct result. Otherwise, it will return false, and the correct settings for the blurriness cannot be obtained.

Parameter

Description

None

None

Return value

Description

boolean

True indicates blurriness detection is turned on, false indicates blurriness detection is turned off.

public static boolean getIlluminationFilterEnable()

Obtain the setting whether brightness detection switch status. Should be called after init to get the correct result. Otherwise, it will return false, and the correct settings for the brightness cannot be obtained.

Parameter

Description

None

None

Return value

Description

boolean

True indicates brightness detection is turned on, false indicates brightness detection is turned off.

public static boolean getOcclusionEnable()

Obtain the setting whether occlusion detection switch status. Should be called after init to get the correct result. Otherwise, it will return false, and the correct settings for the occlusion cannot be obtained.

Parameter

Description

None

None

Return value

Description

boolean

True indicates occlusion detection is turned on, false indicates occlusion detection is turned off.

public static float getThreshold()

Obtain the threshold of liveness detection. Should be called after init to get the correct result. Otherwise, it will return -1.0.

Parameter

Description

None

None

Return value

Description

float

The threshold for liveness detection.

public static int getDetectTimeout()

Obtain the detection timeout time. Should be called after init to get the correct result. Otherwise, it will return -1, indicating that the correct timeout setting can not be obtained.

Parameter

Description

None

None

Return value

Description

int

Detection timeout time (in seconds)

public static int getPassMinDuration()

Obtain the shortest detection time that can pass the liveness detection. Should be called after init to get the correct result. Otherwise, it will return -1.

Parameter

Description

None

None

Return value

Description

int

The shortest time for passing the liveness detection (in seconds)

public static int getPassMinFrames()

Obtain the minimum number of detection frames that can pass the liveness detection. Should be called after init to get the correct result. Otherwise, it will return -1.

Parameter

Description

None

None

Return value

Description

int

Minimum number of detection frames

public static float getFaceFarRate()

Obtain the farthest face distance threshold in the judgment condition. Should be called after init to get the correct result. Otherwise, it will return -1.

Parameter

Description

None

None

Return value

Description

float

Farthest distance threshold

public static float getFaceCloseRate()

Obtain the closest face distance threshold in the judgment condition. Should be called after init to get the correct result. Otherwise, it will return -1.

Parameter

Description

None

None

Return value

Description

float

Closest distance threshold

public static String getSdkVersion()

Get the current SDK version number.

Parameter

Description

None

None

Return value

Description

String

Current SDK version number

public static String getLibraryVersion()

Get the version number of the current internal library. After init succeeded, call this method to get the correct version number of the internal library.

Parameter

Description

None

None

Return value

Description

String

Get the version of the current internal library

Last updated