tencent cloud

Feedback

CompareFaceLiveness

Last updated: 2024-12-09 17:59:49

    1. API Description

    Domain name for API request: faceid.intl.tencentcloudapi.com.

    This interface supports judgment of real person and photo comparison to verify the user's identity online. By passing the video and photo into the interface, it will first judge whether the person in the video is real. If yes, it judges whether the person in the video is the same one as the uploaded photo and returns authentication result.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CompareFaceLiveness.
    Version Yes String Common Params. The value used for this API: 2018-03-01.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-bangkok, ap-hongkong, ap-singapore.
    ImageBase64 Yes String Base64 value of photos used for face comparison.
    The size of image data encoded by Base64 shall not exceed 3M, only jpg and png are supported.
    Please use standard Base64 encoding (use = for padding). Refer to RFC4648 for encoding specifications.
    Example values: "/9j/4AAQSk... (total length:61944)KiiK//2Q=="
    VideoBase64 Yes String Base64 value of videos used for face comparison.
    The size of videos data encoded by Base64 shall not exceed 8M, only mp4,avi,flv are supported.
    Please use standard Base64 encoding (use = for padding). Refer to RFC4648 for encoding specifications.
    Example values: "/9j/4AAQSk... (total length:61944)KiiK//2Q=="
    LivenessType Yes String The liveness detection type. Valid values: ACTION, and SILENT.
    ACTION: Motion mode; SILENT: silent mode. Select one of them.
    Example value: "SILENT"
    ValidateData No String When the "LivenessType" parameter is "ACTION", it must be specified.
    It is used to control the action sequence. Action types:
    1 (open mouth)
    2 (blink)
    3 (nod)
    4 (shake head).
    Select one or two from the four actions.
    Example of passing single action parameter: "1".
    Example of passing multiple action parameters: "4,2".
    When the "LivenessType" parameter value is "SILENT", it shall be unspecified.
    Example value: ""

    3. Output Parameters

    Parameter Name Type Description
    Result String Service error code. When the return value is "Success", it indicates that the liveness detection and face comparison succeeded. It is determined that they are the same person. When the return value is "FailedOperation.CompareLowSimilarity", it indicates that the liveness detection succeeded, and the face comparison similarity is lower than 70 points. It is determined that they are not the same person. For other error cases, please refer to Liveness Face Comparison (Pure API) Error Code (https://www.tencentcloud.com/document/product/1061/55390).
    Example Value: "Success".
    Description String Description of business results.
    Example value: "Success"
    Sim Float This value is valid when the "Result" parameter is "Success" or "FailedOperation.CompareLowSimilarity."
    This value indicates the similarity of face comparison. Value range: [0.00, 100.00]. The false pass rate for threshold 70 is 1 in 1,000, and the false pass rate for threshold 80 is 1 in 10,000.
    Example value: 80.00
    BestFrameBase64 String The optimal screenshot of the video after verification is the value encoded by BASE64, jpg format.
    Note: This field may return "null", indicating that no valid value can be obtained.
    Example values: "/9j/4AAQSk... (total length:142036)s97n//2Q=="
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Liveness detection and face comparison passed. Determined to be the same person.

    Liveness detection and face comparison passed. Determined to be the same person.

    Input Example

    POST / HTTP/1.1
    Host: faceid.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CompareFaceLiveness
    <Common request parameters>
    
    {
        "LivenessType": "SILENT",
        "ImageBase64": "iVBORw0KGg...(total length:121036)s97n//2Q==",
        "VideoBase64": "AAAAGGZ0eX...(total length:1651021)AAwAAAAEecg=",
        "ValidateData": ""
    }
    

    Output Example

    {
        "Response": {
            "Result": "Success",
            "Description": "Success",
            "Sim": 100,
            "BestFrameBase64": "/9j/4AAQSk...(total length:142036)s97n//2Q==",
            "RequestId": "f89097ac-4003-4d73-acb3-696d4057b9eb"
        }
    }
    

    Example2 Liveness detection and face comparison failed. Determined not to be the same person.

    Liveness detection and face comparison failed. Determined not to be the same person.

    Input Example

    POST / HTTP/1.1
    Host: faceid.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CompareFaceLiveness
    <Common request parameters>
    
    {
        "ImageBase64": "iVBORw0KGg...(total length:121036)s97n//2Q==",
        "VideoBase64": "AAAAGGZ0eX...(total length:1651021)AAwAAAAEecg=",
        "LivenessType": "ACTION",
        "ValidateData": "1"
    }
    

    Output Example

    {
        "Response": {
            "Result": "FailedOperation.CompareLowSimilarity",
            "Description": "The comparison similarity did not reach the passing standard.",
            "Sim": 9.21,
            "BestFrameBase64": "/9j/4AAQSk...(total length:138021)8ASrH/2Q==",
            "RequestId": "6176fad1-f078-445b-8a4d-c8a903528b5a"
        }
    }
    

    Example3 Liveness detection failed, the specified action was not detected.

    Liveness detection failed, the specified action was not detected.

    Input Example

    POST / HTTP/1.1
    Host: faceid.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CompareFaceLiveness
    <Common request parameters>
    
    {
        "ImageBase64": "iVBORw0KGg...(total length:121036)s97n//2Q==",
        "VideoBase64": "AAAAGGZ0eX...(total length:1651021)AAwAAAAEecg=",
        "LivenessType": "ACTION",
        "ValidateData": "4,2"
    }
    

    Output Example

    {
        "Response": {
            "Result": "FailedOperation.ActionFirstAction",
            "Description": "The first motion is not detected.",
            "Sim": 0,
            "BestFrameBase64": "/9j/4AAQSk...(total length:161021)W/M7/M/9k=",
            "RequestId": "df5afd82-6469-4a4a-bd62-debf8c2ef94f"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.UnKnown Unknown internal error.
    InvalidParameter Invalid parameter.
    InvalidParameterValue Incorrect parameter value.
    UnauthorizedOperation.Activating Activating the service.
    UnauthorizedOperation.Arrears The account is in arrears.
    UnauthorizedOperation.NonAuthorize Identity verification has not been completed for the account.
    UnauthorizedOperation.Nonactivated The service has not been activated.