tencent cloud

Feedback

GeneralAccurateOCR

Last updated: 2022-08-19 11:24:57

1. API Description

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

This API is used to detect and recognize characters in an image. It can recognize Chinese, English, Chinese-English, digits, and special symbols and return the text box positions and characters.

It is suitable for scenarios with a lot of characters in complex layouts and requiring high recognition accuracy, such as examination papers, online images, signboards, and legal documents.

Strengths: compared with general print recognition, it provides higher-precision character recognition services. Its accuracy and recall rate are higher in difficult scenarios such as a large number of characters, long strings of digits, small characters, blurry characters, and tilted text.

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: GeneralAccurateOCR.
Version Yes String Common Params. The value used for this API: 2018-11-19.
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-beijing, ap-guangzhou, ap-hongkong, ap-shanghai, na-toronto.
ImageBase64 No String Base64-encoded value of image.
The image cannot exceed 7 MB in size after being Base64-encoded. A resolution above 600x800 is recommended. PNG, JPG, JPEG, and BMP formats are supported.
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)
The image cannot exceed 7 MB after being Base64-encoded. A resolution above 600x800 is recommended. PNG, JPG, JPEG, and BMP formats are supported.
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.
IsWords No Boolean Whether to return the character information. Default value: false
EnableDetectSplit No Boolean Whether to slice the input image to enhance the recognition effects for scenarios where the whole image is big, but the size of a single character is small (e.g., test papers). This feature is disabled by default.
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 Number of a PDF page that needs to be recognized. Currently, only one single page can be recognized. This parameter takes effect only if a PDF file is uploaded and IsPdf is set to true. Default value: 1

3. Output Parameters

Parameter Name Type Description
TextDetections Array of TextDetection Information on recognized text, including the text line content, confidence, text line coordinates, and text line coordinates after rotation correction. For more information, please click the link on the left.
Angel Float Image rotation angle in degrees. 0°: The horizontal direction of the text on the image; a positive value: rotate clockwise; a negative value: rotate counterclockwise.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

debugging-tool)">

Example1 Recognizing general print (high-precision) (debugging tool)

Input Example

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

{
    "ImageUrl": "https://xx/a.jpg"
}

Output Example

{
    "Response": {
        "TextDetections": [
            {
                "AdvancedInfo": "xx",
                "Polygon": [
                    {
                        "Y": 231,
                        "X": 449
                    },
                    {
                        "Y": 211,
                        "X": 452
                    },
                    {
                        "Y": 227,
                        "X": 563
                    },
                    {
                        "Y": 247,
                        "X": 560
                    }
                ],
                "Confidence": 99,
                "ItemPolygon": {
                    "Y": 211,
                    "X": 449,
                    "Height": 37,
                    "Width": 115
                },
                "WordCoordPoint": [
                    {
                        "WordCoordinate": [
                            {
                                "Y": 0,
                                "X": 0
                            }
                        ]
                    }
                ],
                "DetectedText": "xx",
                "Words": [
                    {
                        "Confidence": 0,
                        "Character": "xx"
                    }
                ]
            },
            {
                "AdvancedInfo": "xx",
                "Polygon": [
                    {
                        "Y": 308,
                        "X": 361
                    },
                    {
                        "Y": 242,
                        "X": 368
                    },
                    {
                        "Y": 271,
                        "X": 648
                    },
                    {
                        "Y": 338,
                        "X": 641
                    }
                ],
                "Confidence": 99,
                "ItemPolygon": {
                    "Y": 242,
                    "X": 361,
                    "Width": 288,
                    "Height": 97
                },
                "WordCoordPoint": [
                    {
                        "WordCoordinate": [
                            {
                                "Y": 0,
                                "X": 0
                            }
                        ]
                    }
                ],
                "DetectedText": "xx",
                "Words": [
                    {
                        "Confidence": 0,
                        "Character": "xx"
                    }
                ]
            },
            {
                "AdvancedInfo": "xx",
                "Polygon": [
                    {
                        "Y": 349,
                        "X": 394
                    },
                    {
                        "Y": 316,
                        "X": 398
                    },
                    {
                        "Y": 337,
                        "X": 593
                    },
                    {
                        "Y": 371,
                        "X": 589
                    }
                ],
                "Confidence": 99,
                "ItemPolygon": {
                    "Y": 316,
                    "X": 394,
                    "Width": 200,
                    "Height": 56
                },
                "WordCoordPoint": [
                    {
                        "WordCoordinate": [
                            {
                                "Y": 0,
                                "X": 0
                            }
                        ]
                    }
                ],
                "DetectedText": "xx",
                "Words": [
                    {
                        "Confidence": 0,
                        "Character": "xx"
                    }
                ]
            },
            {
                "AdvancedInfo": "xx",
                "Polygon": [
                    {
                        "Y": 401,
                        "X": 381
                    },
                    {
                        "Y": 368,
                        "X": 385
                    },
                    {
                        "Y": 389,
                        "X": 594
                    },
                    {
                        "Y": 422,
                        "X": 590
                    }
                ],
                "Confidence": 98,
                "ItemPolygon": {
                    "Y": 368,
                    "X": 381,
                    "Width": 214,
                    "Height": 55
                },
                "WordCoordPoint": [
                    {
                        "WordCoordinate": [
                            {
                                "Y": 0,
                                "X": 0
                            }
                        ]
                    }
                ],
                "DetectedText": "xx",
                "Words": [
                    {
                        "Confidence": 0,
                        "Character": "xx"
                    }
                ]
            }
        ],
        "RequestId": "xx",
        "Angel": 0.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 The image is empty.
FailedOperation.EngineRecognizeTimeout Recognition by the engine timed out.
FailedOperation.ImageBlur The image is blurry.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.ImageNoText No text is detected in the image.
FailedOperation.ImageSizeTooLarge The image is too large. Please see the description of image size limit in the output parameters.
FailedOperation.OcrFailed OCR failed.
FailedOperation.UnKnowError Unknown error.
FailedOperation.UnOpenError The service is not activated.
InvalidParameter.EngineImageDecodeFailed Image decoding failed.
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