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
Name | Type | Description |
---|---|---|
image1* | String | Base64 encoded binary data of first image. |
image2* | String | Base64 encoded binary data of second image. |
verified_document | Boolean | Whether or not verify that in images have ID card. Note: default value is False. |
image1_is_document | Boolean | To verify whether an image in image1 parameter has ID Card. Note: default value is False. |
image2_is_document | Boolean | To verify whether an image in image2 parameter has ID Card. Note: default value is False. |
blur_detection | Boolean | Whether or not detect blurriness from images. Note: default value is False. |
Return Values
Fields | Type | Description |
---|---|---|
request_id | String | Unique id each request |
confidence | Float | 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. |
thresholds | Object | 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.
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_used | Float | Duration. Unit: second |
error_message | String | This string will not be returned unless request fails. For more details, please see the following section on error message. |
Error Message
HTTP Status | Error Message | Description |
---|---|---|
400 | IMAGE_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. |
200 | CAN_NOT_DETECT_FACE: <param> | The image which <param> does not have face. |
200 | IMAGE_BLURED: <param> | The image which <param> is blured. |
200 | CAN_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
Name | Type | Description |
---|---|---|
image1* | String | Base64 encoded binary data of first image. |
image2* | String | Base64 encoded binary data of second image. |
verified_document | Boolean | Whether or not verify that in images have ID card. Note: default value is False. |
image1_is_document | Boolean | To verify whether an image in image1 parameter has ID Card. Note: default value is False. |
image2_is_document | Boolean | To verify whether an image in image2 parameter has ID Card. Note: default value is False. |
blur_detection | Boolean | Whether or not detect blurriness from images. Note: default value is False. |
- 200: OK
- 422: Unprocessable Entity
{
"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"
}
{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}
- Python
- Nodejs
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())
const axios = require("axios");
const api = "https://apis.aigen.online/aiface/face-compare/v1";
const headers = {
"x-aigen-key": "<key>",
};
const data = {
image1: "<bas64_string>",
image2: "<bas64_string>",
};
axios
.post(api, data, { headers: headers })
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.error(err.response.data);
});