tencent cloud

Feedback

TableOCR

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

    1. API Description

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

    This API is used to detect and recognize Chinese and English forms in images. It can return the text content of each cell and save the recognition result as Excel.

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

    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: TableOCR.
    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.
    ImageBase64 No String Base64-encoded value of image.
    Supported image formats: PNG, JPG, JPEG. GIF is not supported at present.
    Supported image size: the downloaded image cannot exceed 3 MB in size after being Base64-encoded. The download time of the image cannot exceed 3 seconds.
    Either ImageUrl or ImageBase64 of the image must be provided; if both are provided, only ImageUrl will be used.
    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
    TextDetections Array of TextTable Recognized text. For more information, please click the link on the left
    Data String Base64-encoded Excel data.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Recognizing a form

    This example shows you how to recognize a form.

    Input Example

    https://ocr.tencentcloudapi.com/?Action=TableOCR
    &ImageUrl=http%3A%2F%2Fimg3.redocn.com%2Ftupian%2F20180301%2Fkongbaiqiuzhijianlibiaogesheji_9230633.jpg
    &<Common request parameters>
    

    Output Example

    {
        "Response": {
            "TextDetections": [
                {
                    "ColTl": -1,
                    "RowTl": -1,
                    "ColBr": -1,
                    "RowBr": -1,
                    "Text": "Item number",
                    "Type": "header",
                    "Confidence": 99,
                    "Polygon": [
                        {
                            "X": 3378,
                            "Y": 363
                        },
                        {
                            "X": 3383,
                            "Y": 646
                        },
                        {
                            "X": 3304,
                            "Y": 648
                        },
                        {
                            "X": 3299,
                            "Y": 365
                        }
                    ],
                    "AdvancedInfo": "{}"
                },
                {
                    "ColTl": -1,
                    "RowTl": -1,
                    "ColBr": -1,
                    "RowBr": -1,
                    "Text": "Dish/:11181 1 19Medical101",
                    "Type": "header",
                    "Confidence": 53,
                    "Polygon": [
                        {
                            "X": 3470,
                            "Y": 1285
                        },
                        {
                            "X": 3501,
                            "Y": 3092
                        },
                        {
                            "X": 3361,
                            "Y": 3094
                        },
                        {
                            "X": 3330,
                            "Y": 1287
                        }
                    ],
                    "AdvancedInfo": "{}"
                },
                {
                    "ColTl": -1,
                    "RowTl": -1,
                    "ColBr": -1,
                    "RowBr": -1,
                    "Text": "Export declaration form",
                    "Type": "header",
                    "Confidence": 99,
                    "Polygon": [
                        {
                            "X": 3201,
                            "Y": 2046
                        },
                        {
                            "X": 3211,
                            "Y": 2618
                        },
                        {
                            "X": 3169,
                            "Y": 2618
                        },
                        {
                            "X": 3159,
                            "Y": 2046
                        }
                    ],
                    "AdvancedInfo": "{}"
                },
                {
                    "ColTl": -1,
                    "RowTl": -1,
                    "ColBr": -1,
                    "RowBr": -1,
                    "Text": "Production and sales company name (required)",
                    "Type": "header",
                    "Confidence": 98,
                    "Polygon": [
                        {
                            "X": 2525,
                            "Y": 184
                        },
                        {
                            "X": 2532,
                            "Y": 594
                        },
                        {
                            "X": 2491,
                            "Y": 595
                        },
                        {
                            "X": 2484,
                            "Y": 185
                        }
                    ],
                    "AdvancedInfo": "{}"
                }
            ],
            "Data": "bWxQSwECFAAUAAAACAAAAAAAcxSJldcBAAD9BQAADQAAAAAAAAAAAAAAAACtLAAAeGwvc3R5bGVzLnhtbFBLAQIUABQAAAAIAAAAAAC8TIYcSAYAAP4kAAATAAAAAAAAAAAAAAAAAK8uAAB4bC90aGVtZS90aGVtZTEueG1sUEsBAhQAFAAAAAgAAAAAANG5P9oECwAAUU0AABgAAAAAAAAAAAAAAAAAKDUAAHhsL3dvcmtzaGVldHMvc2hlZXQyLnhtbFBLAQIUABQAAAAIAAAAAADjsY7PqAMAAE8PAAAYAAAAAAAAAAAAAAAAAGJAAAB4bC93b3Jrc2hlZXRzL3NoZWV0MS54bWxQSwUGAAAAAAwADAALAwAAQEQAAAAA",
            "RequestId": "98f8fcbf-933a-4e95-ac48-6f1a9308fs53"
        }
    }
    

    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 The image is empty.
    FailedOperation.ImageDecodeFailed Image decoding failed.
    FailedOperation.ImageNoText No text is detected in the image.
    FailedOperation.LanguageNotSupport The input language is not supported.
    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.