Face-ID comparison

更新时间:
复制 MD 格式

Face-to-ID comparison quickly verifies user identities and reduces manual review costs. This feature is widely used for identity authentication, financial services, and hotel check-ins. This topic describes how to compare a face photo with an ID photo by calling multiple Face & Body APIs.

Callable APIs

The face-to-ID comparison scenario is not available as a single API. You can build this capability by calling the following APIs.

Prerequisites

The Face & Body Service is activated. If the service is not activated, you can activate it now.

Note

The APIs in this tutorial can be activated by enterprise or individual users who have completed identity verification. For more information about identity verification, see Identity verification.

Billing

Face Detection and Landmarking (DetectFace), Face Liveness Detection (DetectLivingFace), and 1:1 Face Comparison (CompareFace) are paid APIs. For more information about billing, see Billing of Face & Body.

Input limits

  • Image format: JPEG, JPG, PNG, or BMP.

  • Maximum image size: 5 MB.

  • Image resolution: The image must be larger than 32 × 32 pixels and smaller than 4096 × 4096 pixels. The face in the image must be at least 64 × 64 pixels.

  • The URL cannot contain Chinese characters.

Note

If the image resolution exceeds the maximum limit, you can scale the image to adjust its size. For more information, see Image scaling.

Procedure

  1. Call Face Detection and Landmarking (DetectFace).

    Set the ImageURL request parameter to the URL of the image to test. The call returns the FaceCount parameter.

  2. Check the value of the returned FaceCount parameter.

    • If the value of FaceCount is greater than 0, a face is detected in the image. Proceed to the next step.

    • If the value of FaceCount is 0, no face is detected in the image. The process ends.

  3. Call Face Liveness Detection (DetectLivingFace).

    Set the ImageURL request parameter to the URL of the image to test. The following code shows a sample response.

    "Data": {
      "Elements": [
        {
          "TaskId": "img6xmr38ZM4aU6SYeCmj6SAp-1tde$O",
          "Results": [
            {
              "Suggestion": "review",
              "Rate": 76.51,
              "Label": "normal"
            }
          ],
          "ImageURL": "https://viapi-test.oss-cn-shanghai.aliyuncs.com/demo-center/facebody/DetectLivingFace.jpg"
        }
      ]
    }
  4. Check the value of the returned Label parameter.

    • If the value is normal, the image is a live photo. Proceed to the next step.

    • If the value is liveness, the image is a screen recapture or no face is detected. The process ends.

  5. Call 1:1 Face Comparison (CompareFace).

    Set the ImageURLA and ImageURLB request parameters to the URLs of the face photo and the ID photo to be compared, respectively. The Confidence parameter is returned. The flow ends.

  6. Check the value of the returned Confidence parameter.

    If the value of Confidence is greater than 69, the face-to-ID comparison is successful.

Error codes

For information about the error codes for face detection and landmarking, face liveness detection, and face comparison, see Common error codes for Face & Body.

SDK Reference

You can call Alibaba Cloud Vision AI capabilities using software development kits (SDKs). For more information about how to download and install an SDK, see SDK overview.

Security statement

  • Ensure that the source of uploaded images or files complies with applicable laws and regulations.

  • Temporary files that you upload for testing are accessible for one hour and are automatically deleted by the system after 24 hours.