DFLivenessSDK Class Introduction
DFLivenessSDK(Context context)
The constructor function.
| Parameter | Description |
|---|---|
| Context | Application context |
| Return | Description |
| None | None |
boolean createHandle()
Create SDK handle.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| boolean | True: create successful, false: create failed |
boolean createHandle(String licenseName)
Create SDK handle with customized license name.
| Parameter | Description |
|---|---|
| licenseName | License name |
| Return | Description |
| boolean | True: create successful, false: create failed |
void setThreshold(DFLivenessKey key, float value)
Set liveness parameters.
| Parameter | Description |
|---|---|
| key | The parameter key value, reference to: DFLivenessKey |
| value | The value of key |
| Return | Description |
| None | None |
void start(int config, DFLivenessSDK.DFLivenessMotion[] motions)
Start liveness detection.
| Parameter | Description |
|---|---|
| config | Default format for output type and complexity: output type reference to :DFLivenessSDK.DFLivenessOutputType complexity reference to :DFLivenessSDK.DFLivenessComplexity |
| motions | Action detection list, reference to: DFLivenessMotion |
| Return | Description |
| None | None |
static String getSDKVersion()
Return the SDK version.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| SDK version | None |
DFLivenessSDK.DFStatus detect(byte[] image, int width, int height, int rotateAngle, DFLivenessSDK.DFLivenessMotion motion, boolean isHoldStill)
Detect action in image.
| Parameter | Description |
|---|---|
| image | Input image data |
| width | Image width |
| height | Image height |
| rotateAngle | Image orientation |
| motion | The current action to be detected,reference to DFLivenessMotion |
| isHoldStill | Is it silent |
| Return | Description |
| DFStatus | Reference to DFStatus |
DFLivenessSDK.DFRect getFaceRect() throws Exception
Get face rectangle in the image, An exception is thrown when the call fails.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| DFLivenessSDK.DFRect | Face rectangle |
void end()
End liveness detection.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| None | None |
byte[] getLivenessResult() throws Exception
Get liveness detection result. An exception is thrown when the call fails.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| byte[] | The encrypted liveness detection result |
DFLivenessSDK.DFLivenessImageResult[] getImageResult() throws Exception
Get images from liveness detection. An exception is thrown when the call fails.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| DFLivenessSDK.DFLivenessImageResult[] | DFLivenessSDK.DFLivenessImageResult contains imageBytes which is jpeg image buffer,length which is the length of imageBytes,motion which is the motion of imageBytes |
void destroy()
Destroy the handle and recover the memory.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| None | None |
Internal Class Introduction
DFLivenessOutputType
Liveness output type.
| Type | Description |
|---|---|
| WRAPPER_OUTPUT_TYPE_MULTI_IMAGE | SDK will return several images, the images' number equals to the number of motions |
DFLivenessMotion
Support liveness motion type.
| Type | Description |
|---|---|
| BLINK | Blink |
| MOUTH | Open mouth |
| YAW | Yaw |
| NOD | Nod |
| HOLD_STILL | Hold still |
DFDetectStatus
Liveness detection status, it uses to check current detection status.
| Type | Description |
|---|---|
| PASSED | The detection is passed |
| DETECTING | Detecting |
| INTERNAL_ERROR | Detect error |
| TRACKING_MISSED | Face lossing |
DFStatus
Liveness detect result status.
int getDetectStatus()
Gets the status of the detect results.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| int | Reference to DFDetectStatus |
boolean isPassed()
Whether the current detection passes or not.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| boolean | True: detection passes, false: detection fails |
boolean isHasFace()
Whether there is a face in the image or not.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| boolean | True: there is a face, false: there isn't a face |
boolean isFaceValid()
Whether face is valid or not.
| Parameter | Description |
|---|---|
| None | None |
| Return | Description |
| boolean | True: face is valid, false: face is invalid |
DFLivenessKey
Liveness parameters key.
| Type | Description |
|---|---|
| KEY_BLINK_KEY | Blink threshold type |
| KEY_MOUTH_KEY | Mouth threshold type |
| KEY_YAW_KEY | Yaw threshold type |
| KEY_PITCH_KEY | Nod threshold type |
| KEY_HOLD_STILL | Hold still threshold type |