tencent cloud

Feedback

SmartStructuralOCRV2

Last updated: 2023-06-25 16:05:59

1. API Description

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

This API is used to recognize fields from cards, documents, bills, forms, contracts, and other structured information. It is flexible and efficient to use, without any configuration required. This API is suitable for recognizing structured information.

A maximum of 10 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: SmartStructuralOCRV2.
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.
ImageUrl No String The URL of the image.
Supported image formats: PNG, JPG, and JPEG. GIF is currently not supported.
Supported image size: The downloaded image after Base64 encoding can be up to 7 MB. The download time of the image cannot exceed 3s.
We recommend that you store the image in Tencent Cloud for higher download speed and stability.
The download speed and stability of non-Tencent Cloud URLs may be low.
ImageBase64 No String The Base64-encoded value of the image.
Supported image formats: PNG, JPG, and JPEG. GIF is currently not supported.
Supported image size: The downloaded image after Base64 encoding can be up to 7 MB. The download time of the image cannot exceed 3s.
Either ImageUrl or ImageBase64 of the image must be provided. If both are provided, only ImageUrl is used.
IsPdf No Boolean Whether to enable PDF recognition. Default value: false. If you enable this feature, both images and PDF files can be recognized.
PdfPageNumber No Integer The number of the PDF page that needs to be recognized. Only one single PDF page can be recognized. This parameter is valid if the uploaded file is a PDF and the value of IsPdf is true. Default value: 1.
ItemNames.N No Array of String The names of the fields you want to return for the structured information recognition.
For example, if you want to return only the recognition result of the "Name" and "Gender" fields, set this parameter as follows:
ItemNames=["Name","Gender"]
ReturnFullText No Boolean Whether to enable recognition of all fields.

3. Output Parameters

Parameter Name Type Description
Angle Float The rotation angle (degrees) of the text on the image. 0: The text is horizontal. Positive value: The text is rotated clockwise. Negative value: The text is rotated counterclockwise.
StructuralList Array of GroupInfo The structural information (key-value).
WordList Array of WordItem The recognized text information.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Recognizing structured information

This example shows you how to use the new API for smart structured information OCR.

Input Example

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

{
    "ImageUrl": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/document/SmartStructuralOCR/SmartStructuralOCRV2.jpg"
}

Output Example

{
    "Response": {
        "Angle": 0,
        "StructuralList": [
            {
                "Groups": [
                    {
                        "Lines": [
                            {
                                "Key": {
                                    "AutoName": "abc"
                                },
                                "Value": {
                                    "AutoContent": "abc",
                                    "Coord": {
                                        "LeftTop": {
                                            "X": 0,
                                            "Y": 0
                                        },
                                        "RightTop": {
                                            "X": 0,
                                            "Y": 0
                                        },
                                        "RightBottom": {
                                            "X": 0,
                                            "Y": 0
                                        }
                                    }
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "WordList": [
            {
                "DetectedText": "abc",
                "Coord": {}
            }
        ],
        "RequestId": "abc"
    }
}

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.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.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support