tencent cloud

文档反馈

GeneralAccurateOCR

最后更新时间:2023-03-21 17:36:24

    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 No String Common Params. This parameter is not required for this API.
    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

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

    This example shows you how to detect and recognize characters in an image as a whole, where the text box positions and characters are returned.

    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

    {
        "Angel": 359.989990234375,
        "RequestId": "8c8f6a55-b2ef-42f2-864c-e50a83acc2ad",
        "TextDetections": [
            {
                "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}",
                "Confidence": 99,
                "DetectedText": "\"Good friends, good books,",
                "ItemPolygon": {
                    "Height": 29,
                    "Width": 306,
                    "X": 242,
                    "Y": 95
                },
                "Polygon": [
                    {
                        "X": 242,
                        "Y": 95
                    },
                    {
                        "X": 547,
                        "Y": 95
                    },
                    {
                        "X": 547,
                        "Y": 123
                    },
                    {
                        "X": 242,
                        "Y": 123
                    }
                ],
                "WordCoordPoint": [],
                "Words": []
            },
            {
                "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}",
                "Confidence": 99,
                "DetectedText": "and a sleepy conscience:",
                "ItemPolygon": {
                    "Height": 28,
                    "Width": 279,
                    "X": 254,
                    "Y": 128
                },
                "Polygon": [
                    {
                        "X": 254,
                        "Y": 128
                    },
                    {
                        "X": 532,
                        "Y": 128
                    },
                    {
                        "X": 532,
                        "Y": 155
                    },
                    {
                        "X": 254,
                        "Y": 155
                    }
                ],
                "WordCoordPoint": [],
                "Words": []
            },
            {
                "AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}",
                "Confidence": 99,
                "DetectedText": "this is the ideal life\"",
                "ItemPolygon": {
                    "Height": 27,
                    "Width": 219,
                    "X": 287,
                    "Y": 159
                },
                "Polygon": [
                    {
                        "X": 287,
                        "Y": 159
                    },
                    {
                        "X": 505,
                        "Y": 159
                    },
                    {
                        "X": 505,
                        "Y": 185
                    },
                    {
                        "X": 287,
                        "Y": 185
                    }
                ],
                "WordCoordPoint": [],
                "Words": []
            },
            {
                "AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}",
                "Confidence": 99,
                "DetectedText": "- Mark Twain",
                "ItemPolygon": {
                    "Height": 23,
                    "Width": 125,
                    "X": 331,
                    "Y": 189
                },
                "Polygon": [
                    {
                        "X": 331,
                        "Y": 189
                    },
                    {
                        "X": 455,
                        "Y": 189
                    },
                    {
                        "X": 455,
                        "Y": 211
                    },
                    {
                        "X": 331,
                        "Y": 211
                    }
                ],
                "WordCoordPoint": [],
                "Words": []
            }
        ]
    }
    

    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.
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持