Skip to main content

Face Compare

Compare between the two images if the person in the image is the same person.

Image Requirements

Type : JPG (JPEG), PNG
Format : Base64
Size : Must be over 480*480 pixels
Minimum size of face : The bounding size of a detected face should be over than 112 pixels.

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

Request Parameters

NameTypeDescription

image1*

StringBase64 encoded binary data of first image.

image2*

StringBase64 encoded binary data of second image.
verified_documentBoolean

Whether or not verify that in images have ID card.


Note: default value is False.

image1_is_documentBoolean

To verify whether an image in image1 parameter has ID Card.


Note: default value is False.

image2_is_documentBoolean

To verify whether an image in image2 parameter has ID Card.


Note: default value is False.

blur_detectionBoolean

Whether or not detect blurriness from images.


Note: default value is False.

Return Values

FieldsTypeDescription
request_idStringUnique id each request
confidenceFloat

Indicates 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 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 image uploaded, this string will not be returned.

time_usedFloatDuration. Unit: second
error_messageString

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

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.

200CAN_NOT_DETECT_FACE: <param>The image which <param> does not have face.
200IMAGE_BLURED: <param>The image which <param> is blured.
200CAN_NOT_DETECT_IDCARD: <param>The image which <param> does not have ID card.

Compare between the two images if the person in the image is the same person.

Request Body

NameTypeDescription
image1*StringBase64 encoded binary data of first image.
image2*StringBase64 encoded binary data of second image.
verified_documentBooleanWhether or not verify that in images have ID card. Note: default value is False.
image1_is_documentBooleanTo verify whether an image in image1 parameter has ID Card. Note: default value is False.
image2_is_documentBooleanTo verify whether an image in image2 parameter has ID Card. Note: default value is False.
blur_detectionBooleanWhether or not detect blurriness from images. Note: default value is False.
{
"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/face-compare/v1"
headers = {"x-aigen-key": "<key>", "content-type": "application/json"}
data = json.dumps({
"image1": "<base64_string>",
"image2": "<base64_string>",
})

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