Domain name for API request: ocr.intl.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. |
| 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.automix: 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. |
| PdfPageSize | Integer | Total number of PDF pages to be returned if the image is a PDF. Default value: 0. |
| Angle | Float | |
| RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). 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.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: GeneralBasicOCR
<Common request parameters>
{
"ImageUrl": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/general/GeneralBasicOCR/GeneralBasicOCR-en.png"
}
{
"Response": {
"Angel": 359.989990234375,
"Angle": 359.989990234375,
"Language": "en",
"PdfPageSize": 0,
"RequestId": "7d952452-6cfd-4e11-bfd3-4cf87bda686c",
"TextDetections": [
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}",
"Confidence": 99,
"DetectedText": "MINI",
"ItemPolygon": {
"Height": 21,
"Width": 58,
"X": 342,
"Y": 547
},
"Polygon": [
{
"X": 342,
"Y": 547
},
{
"X": 400,
"Y": 547
},
{
"X": 400,
"Y": 568
},
{
"X": 342,
"Y": 568
}
],
"WordCoordPoint": [],
"Words": []
},
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}",
"Confidence": 96,
"DetectedText": "by",
"ItemPolygon": {
"Height": 15,
"Width": 19,
"X": 360,
"Y": 572
},
"Polygon": [
{
"X": 360,
"Y": 572
},
{
"X": 379,
"Y": 572
},
{
"X": 379,
"Y": 587
},
{
"X": 360,
"Y": 587
}
],
"WordCoordPoint": [],
"Words": []
},
{
"AdvancedInfo": "{\"Parag\":{\"ParagNo\":3}}",
"Confidence": 99,
"DetectedText": "FLOWERPLUS",
"ItemPolygon": {
"Height": 21,
"Width": 85,
"X": 327,
"Y": 593
},
"Polygon": [
{
"X": 327,
"Y": 593
},
{
"X": 412,
"Y": 593
},
{
"X": 412,
"Y": 614
},
{
"X": 327,
"Y": 614
}
],
"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 | Failed to download the file. |
| FailedOperation.EmptyImageError | The image is empty. |
| FailedOperation.EngineRecognizeTimeout | Recognition by the engine timed out. |
| FailedOperation.ImageDecodeFailed | Failed to decode the image. |
| FailedOperation.ImageNoText | No text is detected in the image. |
| FailedOperation.LanguageNotSupport | The input language is not supported. |
| FailedOperation.OcrFailed | OCR recognition failed. This error may be caused by unstable network connections, service anomalies, or other issues. |
| FailedOperation.UnKnowError | Unknown error. |
| FailedOperation.UnOpenError | The service has not been activated. |
| InvalidParameterValue.InvalidParameterValueLimit | Incorrect parameter value. |
| LimitExceeded.TooLargeFileError | The file size exceeds the limit |
| ResourceUnavailable.InArrears | The account has insufficient balance. |
| ResourcesSoldOut.ChargeStatusException | The billing status is abnormal. |
フィードバック