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.
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: GeneralBasicOCR. |
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/PDF. The image/PDF cannot exceed 7 MB after being Base64-encoded. A resolution above 600x800 is recommended. PNG, JPG, JPEG, BMP, and PDF formats are supported. |
ImageUrl | No | String | URL address of image/PDF. (This field is not supported outside Chinese mainland) The image/PDF cannot exceed 7 MB after being Base64-encoded. A resolution above 600x800 is recommended. PNG, JPG, JPEG, BMP, and PDF 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. |
Scene | No | String | Reserved field. |
LanguageType | No | String | Language to recognize 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 : Chinese-English mixzh_rare : supports letters, digits, rare Chinese characters, Traditional Chinese characters, special characters, etc.auto mix : language mixjap : Japanesekor : Koreanspa : Spanishfre : Frenchger : Germanpor : Portuguesevie : Vietnamesemay : Malayrus : Russianita : Italianhol : Dutchswe : Swedishfin : Finnishdan : Danishnor : Norwegianhun : Hungariantha : Thaihi : Hindiara : 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. |
IsWords | No | Boolean | Whether to return the character information. Default value: false |
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°: The horizontal direction of the text on the image; a positive value: rotate clockwise; a negative value: rotate counterclockwise. |
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. |
This example shows you how to recognize characters in multiple scenarios in any layout.
POST / HTTP/1.1
Host: ocr.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: GeneralBasicOCR
<Common request parameters>
{
"ImageUrl": "https://xx/a.jpg"
}
{
"Angel": 359.989990234375,
"Language": "zh",
"PdfPageSize": 0,
"RequestId": "0d82dc94-2fc0-43ce-b4db-9a8450ba99e0",
"TextDetections": [
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}",
"Confidence": 100,
"DetectedText": "\"Good friends, good books,",
"ItemPolygon": {
"Height": 27,
"Width": 305,
"X": 241,
"Y": 93
},
"Polygon": [
{
"X": 241,
"Y": 93
},
{
"X": 546,
"Y": 95
},
{
"X": 546,
"Y": 122
},
{
"X": 241,
"Y": 121
}
],
"WordCoordPoint": [],
"Words": []
},
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}",
"Confidence": 100,
"DetectedText": "and a sleepy conscience:",
"ItemPolygon": {
"Height": 29,
"Width": 279,
"X": 254,
"Y": 123
},
"Polygon": [
{
"X": 254,
"Y": 123
},
{
"X": 533,
"Y": 128
},
{
"X": 533,
"Y": 157
},
{
"X": 254,
"Y": 152
}
],
"WordCoordPoint": [],
"Words": []
},
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}",
"Confidence": 100,
"DetectedText": "this is the ideal life\"",
"ItemPolygon": {
"Height": 26,
"Width": 218,
"X": 286,
"Y": 157
},
"Polygon": [
{
"X": 286,
"Y": 157
},
{
"X": 504,
"Y": 157
},
{
"X": 504,
"Y": 183
},
{
"X": 286,
"Y": 183
}
],
"WordCoordPoint": [],
"Words": []
},
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}",
"Confidence": 100,
"DetectedText": "- Mark Twain",
"ItemPolygon": {
"Height": 21,
"Width": 120,
"X": 334,
"Y": 188
},
"Polygon": [
{
"X": 334,
"Y": 188
},
{
"X": 454,
"Y": 188
},
{
"X": 454,
"Y": 209
},
{
"X": 334,
"Y": 209
}
],
"WordCoordPoint": [],
"Words": []
}
]
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
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?