All pages
Powered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

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

Request parameters

Normal response

Correlations between the verification score threshold and the error rate:

Recommended threshold: greater than 0.7.

Abnormal response

System response code

Possible HTTP status codes

Sample

Curl

Java

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.

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

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

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

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

Name

Type

Instructions

code

int

System response code

message

string

Error Messages

request_id

string

The ID of this request

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

status

Description

400

BAD_REQUEST

404

NOT_FOUND

411

LENGTH_REQUIRED

413

PAYLOAD_TOO_LARGE

500

INTERNAL_ERROR

boolean

invalid image type or corrupted

http://ip:port/identity/liveness_image_verification/stateless
{
    "code": 1000,
    "verification_score": float,
    "request_id": string
}
{
    "code": int,
    "message": string,
    "request_id": string
}
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
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();
    }
}

1 Face Compare (Stateless)

1.2 /identity/multiface_image_omni_verification/stateless

Compare the two photos with multiple faces included and uploaded through the interface to get the similarity score of each pair of faces in the two photos.

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

Request mode

POST

Request URL

Request parameters

Normal response

For example:

Suppose that Photo A corresponding to first_image_file contains two faces (a1, a2); Photo B corresponding to second_image_file contains two faces (b1, b2); a1b1 represents the comparison score of face a1 in Photo A and face b1 in Photo B. The response is like:

Correlations between the verification score threshold and the error rate:

Recommended threshold: greater than 0.7.

Abnormal response

System response code

Possible HTTP status codes

Sample

Curl

Java

No

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

The ID of this request

The image type does not meet the requirements

2006

corrupted image error

Image corrupted

4000

detection failed

Feature extraction failed, no face detected in the image

Name

Type

Required

Description

first_encrypted_image

string

Yes

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

second_encrypted_image

string

Yes

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

auto_rotate

Name

Type

Description

code

int

System response code: 1000

scores

array

The face comparison score of each group of photos

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

face_rects

hash

Face frame in each photo

request_id

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

Name

Type

Description

code

int

System response code

message

string

Error Messages

request_id

string

The ID of this request

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

status

Description

400

BAD_REQUEST

404

NOT_FOUND

411

LENGTH_REQUIRED

413

PAYLOAD_TOO_LARGE

500

INTERNAL_ERROR

boolean

string

invalid image type or corrupted

http://ip:port/identity/multiface_image_omni_verification/stateless
{
    "code": 1000,
    "scores": [ # [[a1b1 face comparison score, a1b2 face comparison score] [a2b1 face comparison score, a2b2 face comparison score]]
        [
            float,
            float,
            float,
            float
        ]
    ],
    "face_rects": { # face frame in each image
        "first_image_face_rects": [ # [[a1 face frame coordinates],[a2 face frame coordinates]]
            [
                int,
                int,
                int,
                int
            ],
            [
                int,
                int,
                int,
                int
            ]
        ],
        "second_image_face_rects": [ # [[b1 face frame coordinates],[b2 face frame coordinates]]
            [
                int,
                int,
                int,
                int
            ],
            [
                int,
                int,
                int,
                int
            ]
        ]
    },
    "request_id": "2c4156bb47794f66a2ed50d5a87e5ca2"
}
{
    "code": int,
    "message": string,
    "request_id": string
}
curl -X POST "http://ip:port/identity/multiface_image_omni_verification/stateless" \
  -d first_encrypted_image=xxx \
  -d second_encrypted_image=xxx \
  -d auto_rotate=true
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class HttpClient {
    public static final String POST_URL = "http://127.0.0.1:3000/identity/multiface_image_omni_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);

        List<NameValuePair> params = new ArrayList<>();

        String firstEncryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_01.jpg")));
        String secondEncryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_02.jpg")));

        params.add(new BasicNameValuePair("first_encrypted_image", firstEncryptedImage));
        params.add(new BasicNameValuePair("second_encrypted_image", secondEncryptedImage));

        post.setEntity(new UrlEncodedFormEntity(params));
        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();
    }
}

1.1 /identity/image_verification/stateless

Compare the two photos including only one face each uploaded through the interface to determine whether the two 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

Request parameters

Normal response

Correlations between the verification score threshold and the error rate:

Recommended threshold: greater than 0.7.

Abnormal response

System response code

Possible HTTP status codes

Sample

Curl

Java

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.

The image type does not meet the requirements

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

Name

Type

Required

Description

first_encrypted_image

string

Yes

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

second_encrypted_image

string

Yes

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

auto_rotate

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

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

Name

Type

Instructions

code

int

System response code

message

string

Error Messages

request_id

string

The ID of this request

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

status

Description

400

BAD_REQUEST

404

NOT_FOUND

411

LENGTH_REQUIRED

413

PAYLOAD_TOO_LARGE

500

INTERNAL_ERROR

boolean

invalid image type or corrupted

http://ip:port/identity/image_verification/stateless
{
    "code": 1000,
    "verification_score": float,
    "request_id": string
}
{
    "code": int,
    "message": string,
    "request_id": string
}
curl -X POST "http://ip:port/identity/image_verification/stateless" \
  -d first_encrypted_image=xxx \
  -d second_encrypted_image=xxx \
  -d auto_rotate=true
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class HttpClient {
    public static final String POST_URL = "http://127.0.0.1:3000/identity/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);

        List<NameValuePair> params = new ArrayList<>();

        String firstEncryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_01.jpg")));
        String secondEncryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_02.jpg")));

        params.add(new BasicNameValuePair("first_encrypted_image", firstEncryptedImage));
        params.add(new BasicNameValuePair("second_encrypted_image", secondEncryptedImage));

        post.setEntity(new UrlEncodedFormEntity(params));
        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();
    }
}

1.4 /identity/silent_image_verification/stateless

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

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

Request mode

POST

Request URL

Request parameters

check_qualitycan currently only evaluate face occlusion. Other evaluation items may be added in the future.

Normal response

The possible results ofliveness_statusare as follows:

Correlations between the verification score threshold and the error rate:

Recommended threshold: greater than 0.7.

Abnormal response

System response code

Possible HTTP status codes

Sample

Curl

Java

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.

return_image

boolean

No

Whether to return the selected frame of face and timestamp of the selected frame of the photo. The default is false. image_timestamp and base64_image are returned only when this value is true and the live detection is passed.

return_face_image

boolean

No

Whether to return the face clipping of the selected frame of the photo. The default is false. base64_face_imageis returned only when this value is true and the live detection is passed.

return_status

boolean

No

Whether to return the error status description. The default is false. liveness_status is returned only when this value is true.

Description of the error status of silent liveness detection. This field is returned when return_status=true

verification_score

float

Face comparison score, recommended threshold: > 0.7. This field is returned when passed=true

image_timestamp

float

Timestamp of the selected frame of image in seconds. This field is returned only when passed=true and return_image=true

base64_image

string

The selected frame of the photo. This field is returned only when passed=true and return_image=true

base64_face_image

string

Face clipping of the selected frame of the photo. This field is returned only when passed=true and return_face_image=true

request_id

string

The ID of this request

The image type does not meet the requirements

4000

detection failed

Feature extraction failed, no face detected in the image

4004

face occlusion

The face is detected, but the eyes, nose, or mouth are partially occluded

4007

liveness silent check failed

Silent liveness detection failed

Name

Type

Required

Description

encrypted_video

string

Yes

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

encrypted_image

string

Yes

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

auto_rotate

Name

Type

Description

code

int

System response code: 1000

passed

boolean

Liveness detection passed or not

liveness_score

float

The score of silent liveness detection (for reference only, please refer to the passed field)

liveness_status

Status

Description

ok

Silent liveness detection passed: the person in the video is real

hack

Silent liveness detection failed, reason: face spoofing (for example, photos taken by the mobile phone)

short_time

Silent liveness detection failed, reason: video time less than 2s

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

Name

Type

Instructions

code

int

System response code

message

string

Error Messages

request_id

string

The ID of this request

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

status

Description

400

BAD_REQUEST

404

NOT_FOUND

411

LENGTH_REQUIRED

413

PAYLOAD_TOO_LARGE

500

INTERNAL_ERROR

boolean

string

invalid image type or corrupted

http://ip:port/identity/silent_image_verification/stateless
{
    "code": int,
    "passed": boolean,
    "liveness_score": float,
    "liveness_status": string,
    "verification_score": float.
    "image_timestamp": float,
    "base64_image": string,
    "base64_face_image": string,
    "request_id": string
}
{
    "code": int,
    "message": string,
    "request_id": string
}
curl -X POST "http://ip:port/identity/silent_image_verification/stateless" \
  -d encrypted_video=xxx \
  -d encrypted_image=xxx \
  -d auto_rotate=true
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class HttpClient {
    public static final String POST_URL = "http://127.0.0.1:3000/identity/silent_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);

        List<NameValuePair> params = new ArrayList<>();

        String encryptedVideo = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/video_01.mp4")));
        String encryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_01.jpg")));

        params.add(new BasicNameValuePair("encrypted_video", encryptedVideo));
        params.add(new BasicNameValuePair("encrypted_image", encryptedImage));
        params.add(new BasicNameValuePair("auto_rotate", "true"));
        params.add(new BasicNameValuePair("return_image", "true"));
        params.add(new BasicNameValuePair("return_face_image", "true"));
        params.add(new BasicNameValuePair("return_status", "true"));

        post.setEntity(new UrlEncodedFormEntity(params));
        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();
    }
}