tencent cloud

APIs

HmtResidentPermitOCR

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-09-11 17:43:29

1. API Description

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

This API recognizes the Residence Permit for Hong Kong, Macao, and Taiwan, China Residents. Its OCR feature supports content detection and recognition of all fields on both sides, including name, sex, date of birth, address, identity card number, issuing authority, validity period, number of issuances, and travel permit number (a key field). It can be applied to information recognition scenarios for Residence Permit for Hong Kong, Macao, and Taiwan, China Residents, such as bank account opening and user registration.

Default API request rate limit: 20 requests/second.

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: HmtResidentPermitOCR.
Version Yes String Common Params. The value used for this API: 2018-11-19.
Region No String Common Params. This parameter is not required.
ImageBase64 No String

Base64 value of the image. Supported image formats: PNG, JPG, JPEG. GIF format is not currently supported. Supported image size: no more than 7M after the downloaded image is Base64-encoded. The image download must complete within 3 seconds.Either ImageUrl or ImageBase64 must be provided. If both are provided, only ImageUrl is used.

ImageUrl No String

Image URL.Supported image formats: PNG, JPG, JPEG. GIF format is not currently supported. Supported image size: no more than 7M after Base64 encoding. Image download time no more than 3 seconds. URLs stored in Tencent Cloud guarantee higher download speed and stability. It is recommended to store images in Tencent Cloud. Speed and stability may be impacted for URLs not stored in Tencent Cloud.

CardSide No String

FRONT: the side with a photo (portrait side),
BACK: the side without a photo (national emblem side),
if this parameter is left empty or incorrect, the front or back side is automatically determined for you.

CropPortrait No Boolean Whether to return the portrait image and position coordinates

3. Output Parameters

Parameter Name Type Description
Name String

Name on the document

Sex String

Gender

Birth String

Date of birth

Address String

Address

IdCardNo String

Identity card number

CardType Integer

0-Front
1-Back

ValidDate String

Document validity period

Authority String

Issuing authority

VisaNum String

Number of issuances

PassNo String Travel permit number
PortraitImageInfo PortraitImageInfo Portrait image and coordinate information
WarnCardInfos Array of Integer Card Warning Information

-9102 Alarm for photocopied certificate
-9103 Alarm for photographed certificate
-9104 Alarm for tamper certificate
-9109 This capability is not enabled. Please contact customer support to activate the alert service
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 HmtResidentPermitOCR API Call

Input Example

POST / HTTP/1.1
Host: ocr.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: HmtResidentPermitOCR
<Common request parameters>

{
    "ImageUrl": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/card/HmtResidentPermitOCR/HmtResidentPermitOCR2.png",
    "CardSide": "FRONT"
}

Output Example

{
    "Response": {
"Address": ""
        "Authority": "",
        "Birth": "1985/2/1",
        "CardType": 0,
        "IdCardNo": "820000198502010022",
"Name": "",
        "PassNo": "",
        "PortraitImageInfo": {
            "ImageCoordinates": {
                "X": 0,
                "Y": 0,
                "Width": 0,
                "Height": 0
            },
            "PortraitImage": ""
        },
        "RequestId": "4685e626-f6ea-4ad8-a099-13933ea4bca9",
"Sex": "",
        "ValidDate": "",
        "VisaNum": "0"
    }
}

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.EmptyImageError Image content is empty.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.ImageNoSpecifiedCard Image is not of the specified card category.
FailedOperation.ImageNoText No text detected in the image.
FailedOperation.NotAppointCard Not the specified document.
FailedOperation.OcrFailed OCR recognition failed.
FailedOperation.UnKnowError Unknown error.
FailedOperation.UnOpenError The service has not been activated.
InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
LimitExceeded.TooLargeFileError File content too large.
ResourceUnavailable.InArrears The account balance is insufficient.
ResourceUnavailable.ResourcePackageRunOut The resource package has been exhausted.
ResourcesSoldOut.ChargeStatusException The billing status is abnormal.

Ajuda e Suporte

Esta página foi útil?

comentários