Documentation

Face Comparison API


Request Example:

curl -X POST "https://api.advance.ai/intl/openapi/face-identity/v1/face-comparison" \
-H "X-ACCESS-TOKEN: {Your Access Token}" \
-H "Content-Type: multipart/form-data" \
-F "firstImage=@/Users/lby/Desktop/firstImage.jpg" \
-F "secondImage=@/Users/lby/Desktop/secondImage.jpg" \
-D "region": "VN"

Request Url

https://api.advance.ai/intl/openapi/face-identity/v1/face-comparison
POST (multipart/form-data)
https://sg-api.advance.ai/intl/openapi/face-identity/v1/face-comparison
POST (multipart/form-data)
https://sg-api.advance.ai/intl/openapi/face-identity/v1/face-comparison
POST (multipart/form-data)

Request Header Parameters

ParameterDescription
X-ACCESS-TOKENstring Please use Token Authentication API to get your access token.

Request Parameters

ParameterDescription
firstImagefile The first picture to be uploaded. Refer to Image Quality Requirements.
secondImagefile The second picture to be uploaded. Refer to Image Quality Requirements.
regionstring The region that the faces belongs to. Refer to ISO ALPHA-2 Country Code

Note:

  • Added support for flip angle photos. Supported flip angles include: 90°, 180°, 270°. If the image is flipped, it will have a certain impact on the accuracy.
  • If there are multiple faces in the photo, the largest face will be selected for comparison.

Image Quality Requirements

The services check and extract the necessary information from the uploaded images, hence please ensure the uploaded images satisfy the following criteria:

  • Is in one of the following image formats: PNG / JPG / JPEG
  • Below 2 MB file size
  • Minimum resolution of 256 x 256
  • Maximum resolution of 4096 x 4096

Response Description

ParameterDescription
codeenum Response's Status Code.
transactionIdstring The request id, the max length is 64.
pricingStrategyenum Whether the request will be charged, enum type: FREE, PAY
messagestring Status Code Explanation.
dataobject The result of the comparison.
extraobject Extra response info (Exception Message).

Response.code

Status CodeMessage
SUCCESSpay OK
NO_FACE_DETECTED_FROM_FIRST_IMAGEpay No Face detected from the uploaded first picture.
NO_FACE_DETECTED_FROM_SECOND_IMAGEpay No Face detected from the uploaded second picture.
FIRST_IMAGE_LOW_QUALITY_FACEpay Face quality is too low of the uploaded first picture.
SECOND_IMAGE_LOW_QUALITY_FACEpay Face quality is too low of the uploaded second picture.
PARAMETER_ERRORfree Invalid image format,image format should be one of jpeg/jpg/png, and request content type should be image/jpeg or image/png.
free Invalid image size,max image size should be less than 2M,and image dimension should be between 256 * 256 and 4096 * 4096.
free Parameter should not be empty.
REGION_WRONGfree Region is wrong.
ERRORfree Server error.

Response.data

FieldDescription
similarityfloat Face similarity rate. Refer to Response.data.similarity
firstFaceobject The face in the first picture.
secondFaceobject The face in the second picture.

Response.data.similarity

Face similarity rate between the 2 uploaded pictures, the rate value is always between the number 0-100, the closer the rate to 100, the more similar the two faces are.

  • If the faces similarity is more than 70, the suggestion is pass.
  • If the faces similarity is from 55 to 70, the suggestion is manual check.
  • If the faces similarity is less than 55,the suggestion is rejection or using other methods to verify the user’s identity.

Response.data.firstFace/secondFace

FieldDescription
idstring The identifier for the face in the picture.
topdouble The pixel size from the top edge of the picture.
bottomdouble The pixel size from the bottom edge of the picture.
leftdouble The pixel size from the left edge of the picture.
rightdouble The pixel size from the right edge of the picture.

Response Examples

SUCCESS

{
    "code":"SUCCESS",
    "message":"OK",
    "data":{
            "similarity":87.0,
            "firstFace":{
                "id":"1",
                "top":113.436279296875,
                "bottom":336.11370849609375,
                "left":259.3328552246094,
                "right":415.51715087890625
                },
            "secondFace":{
                "id":"2",
                "top":111.61112976074219,
                "bottom":253.23887634277344,
                "left":171.38746643066406,
                "right":278.3250427246094
        }
    },
    "extra":null,
    "transactionId":"a910b6279667a977",
    "pricingStrategy":"PAY"
}

NO_FACE_DETECTED_FROM_FIRST_IMAGE

{

    "code":"NO_FACE_DETECTED_FROM_FIRST_IMAGE",
    "message":"No Face detected from the uploaded first picture",
    "data":null,
    "extra":null,
    "transactionId":"880463f1b01c449e",
    "pricingStrategy":"PAY"
}

NO_FACE_DETECTED_FROM_SECOND_IMAGE

{
    "code":"NO_FACE_DETECTED_FROM_SECOND_IMAGE",
    "message":"No Face detected from the uploaded second picture",
    "data":null,
    "extra":null,
    "transactionId":"f8585498452aa230",
    "pricingStrategy":"PAY"
}

FIRST_IMAGE_LOW_QUALITY_FACE

{
    "code":"FIRST_IMAGE_LOW_QUALITY_FACE",
    "message":"Face quality is too low of the uploaded first picture",
    "data":null,
    "extra":null,
    "transactionId":"8f678b4a2607ca3c",
    "pricingStrategy":"PAY"
}

SECOND_IMAGE_LOW_QUALITY_FACE

{
    "code":"SECOND_IMAGE_LOW_QUALITY_FACE",
    "message":"Face quality is too low of the uploaded second picture",
    "data":null,
    "extra":null,
    "transactionId":"bd3d550e751424d2",
    "pricingStrategy":"PAY"
}

REGION_WRONG

{
    "code":"REGION_WRONG",
    "message":"Region is wrong",
    "data":null,
    "extra":null,
    "transactionId":"a83fef16ea49b0fb",
    "pricingStrategy":"FREE"
}

PARAMETER_ERROR

{
    "code":"PARAMETER_ERROR",
    "message":"Parameter should not be empty",
    "data":null,
    "extra":null,
    "transactionId":"a4a31feb8a4d23ce",
    "pricingStrategy":"FREE"
}
{
    "code":"PARAMETER_ERROR",
    "message":"Invalid image size,max image size should be less than 2M,and image dimension should be between 256 * 256 and 4096 * 4096",
    "data":null,
    "extra":null,
    "transactionId":"cd9244088a1be373",
    "pricingStrategy":"FREE"
}
{
    "code":"PARAMETER_ERROR",
    "message":"Invalid image format,image format should be one of jpeg/jpg/png,and request content type should be image/jpeg or image/png",
    "data":null,
    "extra":null,
    "transactionId":"9f37bfcdfd00cee8",
    "pricingStrategy":"FREE"
}

ERROR

{
    "code":"ERROR",
    "message":"Server error",
    "data":null,
    "extra":null,
    "transactionId":"1deae5a13ef2bd5e",
    "pricingStrategy":"FREE"

}