GeneralBasicOCR

Last updated: 2020-09-18 17:22:05

    1. API Description

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

    This API is used to detect and recognize characters in an image in the following 20 languages: Chinese, English, Japanese, Korean, Spanish, French, German, Portuguese, Vietnamese, Malay, Russian, Italian, Dutch, Swedish, Finnish, Danish, Norwegian, Hungarian, Thai, and Arabic. Mixed characters in English and each supported language can be recognized together.

    It can recognize printed text in paper documents, online images, ads, signboards, menus, video titles, profile photos, etc.

    Strengths: it can automatically recognize the text language, return the text box coordinate information, and automatically rotate tilted text to the upright direction.

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

    A maximum of 20 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 parameter. The value used for this API: GeneralBasicOCR.
    Version Yes String Common parameter. The value used for this API: 2018-11-19.
    Region Yes String Common parameter. For more information, please see the list of regions supported by the product. This API only supports: ap-beijing, ap-guangzhou, ap-hongkong, ap-seoul, ap-shanghai, na-toronto
    ImageBase64 No String Base64-encoded value of image/PDF.
    The image/PDF cannot exceed 7 MB in size after being Base64-encoded. A resolution above 600x800 is recommended. PNG, JPG, JPEG, BMP, and PDF formats are supported.
    Scene No String Reserved field.
    LanguageType No String Language to be recognized.
    The language can be automatically recognized or manually specified. Chinese-English mix (zh) is selected by default. Mixed characters in English and each supported language can be recognized together.
    Valid values:
    zh\auto\jap\kor<br/>spa\fre\ger\por<br/>vie\may\rus\ita<br/>hol\swe\fin\dan<br/>nor\hun\tha\lat\ara
    Value meanings:
    Chinese-English mix, automatic recognition, Japanese, Korean,
    Spanish, French, German, Portuguese,
    Vietnamese, Malay, Russian, Italian,
    Dutch, Swedish, Finnish, Danish,
    Norwegian, Hungarian, Thai, Latin,
    Arabic.
    IsPdf No Boolean Whether to enable PDF recognition. Default value: false. After this feature is enabled, both images and PDF files can be recognized at the same time.
    PdfPageNumber No Integer Page 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 the IsPdf parameter is true. Default value: 1.

    3. Output Parameters

    Parameter Name Type Description
    TextDetections Array of TextDetection Information of 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.
    Language String Detected language. For more information on the supported languages, please see the description of the LanguageType input parameter.
    Angel Float Image rotation angle in degrees. 0° indicates horizontal text, a positive value indicates clockwise rotation, and a negative value indicates anticlockwise rotation.
    PdfPageSize Integer Total number of PDF pages to be returned if the image is a PDF. Default value: 0.
    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 (debugging tool)

    Input Example

    https://ocr.tencentcloudapi.com/?Action=GeneralBasicOCR
    &ImageBase64=xxxxx
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "TextDetections": [
          {
            "DetectedText": "Confetteria",
            "Confidence": 99,
            "ItemPolygon": {
              "X": 473,
              "Y": 273,
              "Width": 112,
              "Height": 22
            },
            "Polygon": [
              {
                "X": 450,
                "Y": 211
              },
              {
                "X": 560,
                "Y": 223
              },
              {
                "X": 558,
                "Y": 244
              },
              {
                "X": 448,
                "Y": 232
              }
            ],
            "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"
          },
          {
            "DetectedText": "Raffaello",
            "Confidence": 99,
            "ItemPolygon": {
              "X": 396,
              "Y": 304,
              "Width": 282,
              "Height": 68
            },
            "Polygon": [
              {
                "X": 370,
                "Y": 233
              },
              {
                "X": 649,
                "Y": 265
              },
              {
                "X": 642,
                "Y": 331
              },
              {
                "X": 362,
                "Y": 299
              }
            ],
            "AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}"
          },
          {
            "DetectedText": "Ferrero Rocher Confetteria",
            "Confidence": 99,
            "ItemPolygon": {
              "X": 437,
              "Y": 385,
              "Width": 188,
              "Height": 32
            },
            "Polygon": [
              {
                "X": 402,
                "Y": 318
              },
              {
                "X": 587,
                "Y": 339
              },
              {
                "X": 584,
                "Y": 370
              },
              {
                "X": 398,
                "Y": 349
              }
            ],
            "AdvancedInfo": "{\"Parag\":{\"ParagNo\":3}}"
          },
          {
            "DetectedText": "Raffaello",
            "Confidence": 99,
            "ItemPolygon": {
              "X": 427,
              "Y": 435,
              "Width": 207,
              "Height": 34
            },
            "Polygon": [
              {
                "X": 386,
                "Y": 366
              },
              {
                "X": 591,
                "Y": 390
              },
              {
                "X": 587,
                "Y": 423
              },
              {
                "X": 382,
                "Y": 399
              }
            ],
            "AdvancedInfo": "{\"Parag\":{\"ParagNo\":3}}"
          }
        ],
        "Language": "zh",
        "Angel": 6.5,
        "PdfPageSize": 0,
        "RequestId": "03e66873-5209-4d26-abee-c4acd66fab91"
      }
    }

    5. Developer Resources

    API Explorer

    This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

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

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help