Skip to main content

Liveness Detection

API Documentation for Liveness Detection

Overview

Liveness detection is the process of detecting the presence of a live user, rather than a representation such as a picture or fake video. The user needs to do 3 actions (for more details, please see the following actions table) to pass the liveness test(one round). If the user doesn’t pass the liveness test 3 rounds, the API will respond with the status “uncompleted” which means the billing will also count, else the API will respond with status "processing" or "completed".

Image Requirements

Type : JPG (JPEG), PNG
Format : Base64 Size : Must be over 112x112 pixels

How to use liveness detection API

1. Call Get Choices API to get request ID and actions.
2. Call Liveness Detection API with image and request ID, then the liveness detection API will check if the person in the image acts the correct action. You can call Liveness Detection API repeatly until action correct or your time's up. Time limit is up to user but we suggest as 10 second for 1 action.
3. In case that you don't pass the liveness detection until time's up, you can call Liveness Detection API with restartid parameter True to get new choices. and do the second step again.
4. In case that you pass, you will get 3 images that you just pass the test. You can use these 3 images for other service such as Face Compare
.

Request Parameter

Name

Type

Description

request_id*

String

Unique ID each session that you can get from Get Choices API

imageStringBase64 encoded binary data of image
restart_idBoolean

If True, API will return new choices and count as liveness detection fail 1 time. If fail 3 times, this request ID will expired.

Note: The default value is False.

Return Values

Fields

Type

Description
request_idStringUnique ID each session
resultString

Any Liveness result returns when completed an input uploading

  • "Yes" means the action is correct
  • "No" means the action is incorrect

Note: if no image uploaded, this string will not be returned

statusString

Process request status showing as either "processing" or "completed", and if it fail 3 times, will show as "incompleted"

imagesString

Returns images generated after post-processing a liveness detection.

Note: This field is returned only if the status is "completed".

choicesString

Returns the list of action options generated after post-processing a liveness detection. These actions represent the possible choices that the user may be prompted to perform during the session.

Note: This field is only returned if the status is "completed".

next_choiceString

Next action from the list. For more details, please see the following actions table

error_messageString

This string will return when request fails. For more details, please see the following error message

time_usedFloatDuration. Unit: second

Actions

ActionDescription

Part

Turn_rightTurn rightFace
Turn_leftTurn leftFace
Look_upLook upFace
Look_downLook downFace
Open_mouthOpen mouthFace
SmilesmileFace
Like_right_handThumbs up using your right handHand
Like_left_handThumbs up using your left handHand
I_love_you_right_handShow I love you by your right handHand
I_love_you_left_handShow I love you by left right handHand
Ok_right_handShow Okay sign with your right handHand
Ok_left_handShow Okay sign with your left handHand
Handful_right_handShow your right fistHand
Handful_left_handShow your left fistHand
One_right_handShow one finger with your right handHand
One_left_handShow one finger with your left handHand
Two_right_handShow two fingers with your right handHand
Two_left_handShow two fingers with your left handHand
Three_right_handShow three fingers with your right handHand
Three_left_handShow three fingers with your left handHand
Four_right_handShow four fingers with your right handHand
Four_left_handShow four fingers with your left handHand
Forehand_right_handShow the front of your right handHand
Forehand_left_handShow the front of your left handHand
Backhand_right_handShow the back of your right handHand
Backhand_left_handShow the back of your left handHand
Victory_right_handShow victory sign with your right handHand
Victory_left_handShow victory sign with your left handHand
Right_handLift Up your right handHand
Left_handLift Up your left handHand

Error Message

HTTP StatusError MessageDescription
400IMAGE_ERROR_UNSUPPORTED_FORMAT: <param>

The image which <param> indicates can not be resolved. The file format may not be supported or the file is damaged.

400MISSING_ARGUMENTS: <key>Some required arguments missed.
400BAD_ARGUMENTS: <key>

Error while parsing some arguments. This error may be caused by illegal type or length of argument.

Select Choices

Overview

Get choices data which will be used in the Liveness Detection API.

Request Parameter

NameTypeDescription
RequiredmodeInteger Optional

Choose number for livesness actions example 1 - random 1 action

Note: The default value is 3

partString

Choose part "face" and "hand" example choose "face" part will return random actions in face actions example Turn_left, Look_up

Note: The default value is None

selectString

Specific choices to random example Turn_left, Turn_right, Left_hand, Backhand_right_hand

Note: The default value is None

Return Values

FieldsTypeDescription
request_idStringUnique ID each session
statusStringProcess request status showing as "processing"
next_choiceStringNext action from the list
time_usedFloatDuration. Unit: second.

Error Message

HTTP StatusError MessageDescription
400OVER_ARGUMENTS: <param><param> Number more than the limit supported.
400THE NUMBER OF CHOICES NOT ENOUGH: <key>List less than actions select.
400BAD_ARGUMENTS: <key>

Error while parsing some arguments. This error may be caused by illegal type or length of argument.

Get choices data which will be used in the Liveness Detection API.

GET https://apis.aigen.online/aiface/liveness-detection/v1

Query Parameters

NameTypeDescription
mode*IntegerChoose number for livesness actions example 1 - random 1 action Note: The default value is 3
partStringChoose part "face" and "hand" example choose "face" part will return random actions in face actions example Turn_left, Look_up Note: The default value is None
selectStringSpecific choices to random example Turn_left, Turn_right, Left_hand, Backhand_right_hand Note: The default value is None
{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}

Liveness Detection API

POST https://apis.aigen.online/aiface/liveness-detection/v1

Request Body

NameTypeDescription
request_id*StringUnique ID each session that you can get from Get Choices API
image*StringBase64 encoded binary data of image
restart_id*BooleanIf True, API will return new choices and count as liveness detection fail 1 time. If fail 3 times, this request ID will expired. Note: The default value is False.
{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}

Example code

aiFace Liveness Detection