tencent cloud

文档反馈

HKIDCardOCR

最后更新时间:2023-10-12 16:33:21

    1. API Description

    Domain name for API request: ocr.tencentcloudapi.com.

    This API is used to recognize key fields on the photo side of a Hong Kong (China) identity card, including name in Chinese, name in English, telecode for name, date of birth, gender, document symbol, date of the first issue, date of the last receipt, identity card number, and permanent residency attribute.

    This API is not fully available for the time being. For more information, please contact your Tencent Cloud sales rep.

    A maximum of 5 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: HKIDCardOCR.
    Version Yes String Common Params. The value used for this API: 2018-11-19.
    Region No String Common Params. This parameter is not required for this API.
    DetectFake Yes Boolean Whether to check for authenticity.
    ReturnHeadImage Yes Boolean Whether to return identity photo.
    ImageBase64 No String Base64 string of the image
    Supported image formats: PNG, JPG, JPEG. GIF is not supported yet.
    Supported image size: The downloaded image cannot exceed 7 MB after being Base64-encoded, and it cannot take longer than 3 seconds to download the image.
    ImageUrl No String URL address of image. (This field is not supported outside Chinese mainland)
    Supported image formats: PNG, JPG, JPEG. GIF is currently not supported.
    Supported image size: the downloaded image cannot exceed 3 MB after being Base64-encoded. The download time of the image cannot exceed 3 seconds.
    We recommend you store the image in Tencent Cloud, as a Tencent Cloud URL can guarantee higher download speed and stability.
    The download speed and stability of non-Tencent Cloud URLs may be low.

    3. Output Parameters

    Parameter Name Type Description
    CnName String Name in Chinese
    EnName String Name in English
    TelexCode String Telecode for the name in Chinese
    Sex String Gender. Valid values: Male, Female
    Birthday String Date of birth
    Permanent Integer Permanent identity card.
    0: non-permanent;
    1: permanent;
    -1: unknown.
    IdNum String Identity card number
    Symbol String Document symbol, i.e., the symbol under the date of birth, such as "***AZ"
    FirstIssueDate String First issue date
    CurrentIssueDate String Last receipt date
    FakeDetectResult Integer Authenticity check.
    0: unable to judge (because the image is blurred, incomplete, reflective, too dark, etc.);
    1: forged;
    2: authentic.
    Note: this field may return null, indicating that no valid values can be obtained.
    HeadImage String Base64-encoded identity photo
    Note: this field may return null, indicating that no valid values can be obtained.
    WarningCode Array of Integer Multiple alarm codes. If the ID card is spoofed, photocopied, or photoshopped, the corresponding alarm code will be returned.
    -9102: Alarm for photocopied document
    -9103: Alarm for spoofed document
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Recognizing Hong Kong (China) identity card

    Input Example

    https://ocr.tencentcloudapi.com/?Action=HKIDCardOCR
    &ImageUrl=https://xx/a.jpg &DetectFake=true&ReturnHeadImage=false
    &<Common request parameters>
    

    Output Example

    {
        "Response": {
            "CnName": "",
            "EnName": "SAN, Nan",
            "TelexCode": "300000000000",
            "Sex": "Female",
            "Birthday": "01-01-2001",
            "Permanent": 1,
            "IdNum": "C000000(E)",
            "Symbol": "***AZ",
            "FirstIssueDate": "(09-99)",
            "CurrentIssueDate": "23-09-10",
            "FakeDetectResult": 1,
            "WarningCode": [
                -9102,
                -9103
            ],
            "RequestId": "fba1c9ad-aeb3-4418-9ecf-80ab1b5fc875"
        }
    }
    

    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.DownLoadError File download failed.
    FailedOperation.ImageDecodeFailed Image decoding failed.
    FailedOperation.NoHKIDCard Not a Hong Kong identity card.
    FailedOperation.OcrFailed OCR failed.
    FailedOperation.UnKnowError Unknown error.
    FailedOperation.UnOpenError The service is not activated.
    InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
    LimitExceeded.TooLargeFileError The file is too large.
    ResourcesSoldOut.ChargeStatusException Exceptional billing status.