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://api.aigen.online/aiface/face-compare/v3

Request Parameters

NameTypeDescription

image1*

StringBase64 encoded binary data of the first image.

image2*

StringBase64 encoded binary data of the second image.
thresholdInteger

The similarity threshold [0, 100] determines whether two faces match or not. Setting the threshold to 0 always returns a similarity score.


Note: default value is 80.

verified_documentBoolean

Whether or not to verify that the image contains an ID card.


Note: default value is False.

image1_is_documentBoolean

To verify whether image1 contains an ID Card.


Note: default value is False.

image2_is_documentBoolean

To verify whether image2 contains an ID Card.


Note: default value is False.

Return Values

FieldsTypeDescription
request_idStringUnique ID for each request.
scoreFloat

A similarity score [0,100] indicating the similarity of two faces. A higher score indicates a higher possibility that two faces belong to the same person.

Note: if no face is detected within the image uploaded or the two faces do not match each other, this field will not be returned.

matchBooleanA boolean indicating whether the two faces match or not.
time_usedFloatDuration. Unit: second
error_messageString

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

Error Message

HTTP StatusError MessageDescription
200Face comparison successful.
400FACE_NOT_DETECTEDA face was not detected in one or both images.
400ID_CARD_NOT_DETECTED: <image>The image <image> does not contain an ID card.
400ID_CARD_DETECTION_ERROR: <image>An error occurs during ID card detection.
400IMAGE_ERROR_UNSUPPORTED_FORMAT: <image>

The image <image> cannot be processed. The file format may not be supported or the file is damaged.

422The request contains invalid request schema.

Response Examples

{
"request_id": "string",
"score": 99.80358123779297,
"match": true,
"time_used": 2.168225316999724
}

Code Examples

import requests
import json

api = "https://api.aigen.online/aiface/face-compare/v3"
headers = {"x-aigen-key": "<key>", "content-type": "application/json"}
data = json.dumps({
"image1": "<base64_string>",
"image2": "<base64_string>",
"threshold": 80,
})

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