1.3 /identity/liveness_image_verification/stateless

Compare the photo and the liveness data uploaded through the interface to determine whether the faces belong to the same person.

For photo standards, refer to Chapter 3 Photo and Video Standards in the Operation Manual.

Request mode

POST

Request URL

http://ip:port/identity/liveness_image_verification/stateless

Request parameters

Name

Type

Required

Description

liveness_file

file

Yes

The encrypted binary stream file (i.e., protobufData) returned after the successful detection by interactive liveness or silent liveness SDK is already encrypted without additional encryption required

encrypted_image

string

Yes

Encrypted photo Encryption method reference: [Photo and Video Encryption]

auto_rotate

boolean

No

The default value is false, indicating that the photo is not rotated. When the value is true, the photo is automatically rotated.

check_quality

boolean

No

The default value is false, and no quality test is performed. When the value is true, the photo quality is checked.

Normal response

Name

Type

Instructions

code

int

System response code: 1000

verification_score

float

The face comparison score is from 0-1. The greater the value, the greater the probability that the two faces belong to the same person.

request_id

string

The ID of this request

{
    "code": 1000,
    "verification_score": float,
    "request_id": string
}

Correlations between the verification score threshold and the error rate:

Threshold

0.4

0.5

0.6

0.7

0.8

0.9

error rate

1/10

1/100

1/1000

1/10,000

1/100,000

1/1,000,000

Recommended threshold: greater than 0.7.

Abnormal response

Name

Type

Instructions

code

int

System response code

message

string

Error Messages

request_id

string

The ID of this request

{
    "code": int,
    "message": string,
    "request_id": string
}

System response code

code

Field value

Description

1200

invalid argument

Invalid input parameter

2003

invalid image size

The image size (height and width in pixel) does not meet the requirements

2004

invalid content length

The image file size does not meet the requirements

2005

invalid image type or corrupted

The image type does not meet the requirements

2007

corrupted liveness data error

Liveness data corruption

4000

detection failed

Feature extraction failed, no face detected in the image

4004

face occlusion

Face detected but partially obscured by eyes, nose, or mouth

Possible HTTP status codes

status

Description

400

BAD_REQUEST

404

NOT_FOUND

411

LENGTH_REQUIRED

413

PAYLOAD_TOO_LARGE

500

INTERNAL_ERROR

Sample

Curl

curl -X POST "http://ip:port/identity/liveness_image_verification/stateless" \
  -F liveness_file=@/PATH/TO/FILE \
  -d encrypted_image=xxx \
  -d auto_rotate=true

Java

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class HttpClient {
    public static final String POST_URL = "http://127.0.0.1:3000/identity/liveness_image_verification/stateless";
    private static AESCipher cipher = new AESCipher("dcbbad6765e14139a07d34b92292a672", "df25d188a061");

    public static void Post() throws Exception {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPost post = new HttpPost(POST_URL);

        MultipartEntityBuilder entity = MultipartEntityBuilder.create();
        String encryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_01.jpg")));

        entity.addPart("liveness_file", new FileBody(new File("src/main/resources/mobile.protobuf")));
        entity.addPart("encrypted_image", new StringBody(encryptedImage));
        entity.addPart("auto_rotate", new StringBody("true"));

        post.setEntity(entity.build());
        HttpResponse response = httpclient.execute(post);

        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity respEntity = response.getEntity();
            BufferedReader reader = new BufferedReader(new InputStreamReader(respEntity.getContent()));
            String line = reader.readLine();
            System.out.println(line);
        } else {
            HttpEntity respEntity = response.getEntity();
            String responseString = EntityUtils.toString(respEntity);
            System.out.println("error:" + response.getStatusLine().getStatusCode()
                    + "  " + response.getStatusLine().getReasonPhrase());
            System.out.println("cause of error:"+responseString);
        }
    }

    public static void main(String[] args) throws Exception {
        Post();
    }
}

Last updated