Skip to main content

Selfie Face Comparison

Overview

Compare face with face in ID card and decide whether they are from the same person

Image Requirements

Format : JPG (JPEG), PNG
Size : between 112 x 112 and 4096 x 4096 (pixels)
Minimal size of face : The bounding box of a detected face is a square. The minimal side length of a square should be no less than 112 pixels.

Return Values

FieldTypeDescription
request_idStringUnique id of each request
confidenceFloat

ndicates the similarity of two faces, a floating-point number with 2 decimal places between [0,100]. Higher confidence indicates higher possibility that two faces belong to same person. Note: if no face is detected within the image uploaded, this string will not be returned.

thresholdsObject

A set of thresholds including 3 floating-point numbers with 2 decimal places between [0,100]. If the confidence does not meet the "err_01" threshold, it is highly suggested that the two faces are not from the same person. While if the confidence is beyond the "err_0001" threshold, there's high possibility that they are from the same person.

err_01: confidence threshold at the 0.1% error rate; err_001: confidence threshold at the 0.01% error rate; err_0001: confidence threshold at the 0.001% error rate;

Note: seeing that thresholds are not static, there's no need to store values of thresholds in a persistent form, especially not to compare the confidence with a previously returned threshold. If no face is detected within the image uploaded, this string will not be returned.

time_usedFloatTime that the whole request takes. Unit: second
error_messageString

This string will not be returned unless request fails. For more details, please see the following section on error message.

Response Definition

HTTP statusError MessageDescription
200CAN_NOT_DETECT_FACEThe image which don't have face.
200GOT_ONE_FACEThe image which has only one face.
400IMAGE_ERROR_UNSUPPORTED_FORMATThe image which indicates can not be resolved. The file format may not be supported or the file is damaged.

Compare face with face in ID card and decide whether they are from the same person

POST https://apis.aigen.online/aiface/selfie-doc-compare/v1

Request Body

NameTypeDescription
image*StringBase64 encoded binary data of image
{
"request_id": "string",
"confidence": 100,
"thresholds": {
"err_01": 45.92,
"err_001": 54.36,
"err_0001": 59.71
},
"time_used": 0,
"error_message": "error_message"
}
import requests
import json

api = "https://apis.aigen.online/aiface/selfie-doc-compare/v1"
headers = {"x-aigen-key": "<key>", "content-type": "application/json"}
data = json.dumps({
"image": "<base64_string>"
})

res = requests.post(api, data=data, headers=headers)
print(res.json())