Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
阿里云文字识别
https://help.aliyun.com/zh/ocr
Admin
阿里云文字识别(OCR)可以将图片中的文字信息转换为可编辑文本,并根据业务场景提供通用、证照、票据、教育、车辆、企业资质、小语种等多种识别服务。
Tokens:
944,813
Snippets:
2,358
Trust Score:
10
Update:
10 months ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Example Response Source: https://help.aliyun.com/zh/ocr/developer-reference/api-recognizehandwriting An example of a successful response from the Aliyun OCR API. ```APIDOC ## Example ### Success Response (200) This is an example of a normal JSON response from the API. ```json { "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD00655", "Data": "{\"content\":\"炼句 提问方式 1.请赏析诗歌某一联(句) 2.赏析某一联(句)的妙处 3.请赏析诗歌某、角度抒胸意、借景抒情、托物\", \"height\":1277, \"orgHeight\":1277, \"orgWidth\":1080, \"prism_version\":\"1.0.9\", \"prism_wnum\":26, \"prism_wordsInfo\":[{\"angle\":-87, \"direction\":0, \"height\":83, \"pos\":[{\"x\":177, \"y\":56}, {\"x\":260, \"y\":60}, {\"x\":259, \"y\":88}, {\"x\":176, \"y\":84}], \"prob\":96, \"width\":28, \"word\":\"炼句\", \"x\":203, \"y\":30}], \"width\":1080}", "Code": "noPermission", "Message": "You are not authorized to perform this operation." } ``` ``` -------------------------------- ### Example Response Source: https://help.aliyun.com/zh/ocr/developer-reference/api-recognizeedupapercut Provides an example of a normal response in JSON format. ```APIDOC ## Example ### Success Response Example ```json { "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD00655", "Data": "{\"page_list\":[{\"angle\":0,\"doc_index\":1,\"height\":7000,\"orgHeight\":7000,\"orgWidth\":4716,\"page_id\":-1,\"subject_list\":[{\"content_list_info\":[{\"doc_index\":1,\"pos\":[{\"x\":337,\"y\":1644},{\"x\":2313,\"y\":1641},{\"x\":2313,\"y\":2234},{\"x\":337,\"y\":2234}]}],\"ids\":[\"1\"],\"is_multipage\":false,\"prism_wordsInfo\":[{\"pos\":[{\"x\":337,\"y\":1644},{\"x\":2313,\"y\":1641},{\"x\":2313,\"y\":1715},{\"x\":337,\"y\":1719}],\"word\":\"1.[2017·高密期末]三角形按角分类可以分为()\"},{\"pos\":[{\"x\":462,\"y\":1777},{\"x\":1925,\"y\":1774},{\"x\":1925,\"y\":1846},{\"x\":462,\"y\":1849}],\"word\":\"A.锐角三角形、直角三角形、钝角三角形\"},{\"pos\":[{\"x\":456,\"y\":1904},{\"x\":2004,\"y\":1904},{\"x\":2004,\"y\":1976},{\"x\":456,\"y\":1976}],\"word\":\"B.等腰三角形、等边三角形、不等边三角形\"},{\"pos\":[{\"x\":456,\"y\":2034},{\"x\":1633,\"y\":2033},{\"x\":1633,\"y\":2104},{\"x\":456,\"y\":2105}],\"word\":\"C.直角三角形、等腰直角三角形\"},{\"pos\":[{\"x\":453,\"y\":2164},{\"x\":1261,\"y\":2164},{\"x\":1261,\"y\":2233},{\"x\":453,\"y\":2234}],\"word\":\"D.以上答案都不正确\"}],\"text\":\"1.[2017·高密期末]三角形按角分类可以分为( ) A.锐角三角形、直角三角形、钝角三角形B. 等腰三角形、等边三角形、不等边三角形C.直角三角形、等腰直角三角形D.以上答案都不正确\"}],\"width\":4716}]", "Code": "noPermission", "Message": "You are not authorized to perform this operation." } ``` ``` -------------------------------- ### Normal Response Example Source: https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizeedupapercut Example of a successful response from the Aliyun OCR API. ```APIDOC ## Request Example ```json { "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD00655", "Data": "{\"page_list\":[{\"angle\":0,\"doc_index\":1,\"height\":7000,\"orgHeight\":7000,\"orgWidth\":4716,\"page_id\":-1,\"subject_list\":[{\"content_list_info\":[{\"doc_index\":1,\"pos\":[{\"x\":337,\"y\":1644},{\"x\":2313,\"y\":1641},{\"x\":2313,\"y\":2234},{\"x\":337,\"y\":2234}]}],\"ids\":[\"1\"],\"is_multipage\":false,\"prism_wordsInfo\":[{\"pos\":[{\"x\":337,\"y\":1644},{\"x\":2313,\"y\":1641},{\"x\":2313,\"y\":1715},{\"x\":337,\"y\":1719}],\"word\":\"1.[2017·高密期末]三角形按角分类可以分为()\"},{\"pos\":[{\"x\":462,\"y\":1777},{\"x\":1925,\"y\":1774},{\"x\":1925,\"y\":1846},{\"x\":462,\"y\":1849}],\"word\":\"A.锐角三角形、直角三角形、钝角三角形\"},{\"pos\":[{\"x\":456,\"y\":1904},{\"x\":2004,\"y\":1904},{\"x\":2004,\"y\":1976},{\"x\":456,\"y\":1976}],\"word\":\"B.等腰三角形、等边三角形、不等边三角形\"},{\"pos\":[{\"x\":456,\"y\":2034},{\"x\":1633,\"y\":2033},{\"x\":1633,\"y\":2104},{\"x\":456,\"y\":2105}],\"word\":\"C.直角三角形、等腰直角三角形\"},{\"pos\":[{\"x\":453,\"y\":2164},{\"x\":1261,\"y\":2164},{\"x\":1261,\"y\":2233},{\"x\":453,\"y\":2234}],\"word\":\"D.以上答案都不正确\"}],\"text\":\"1.[2017·高密期末]三角形按角分类可以分为( ) A.锐角三角形、直角三角形、钝角三角形B. 等腰三角形、等边三角形、不等边三角形C.直角三角形、等腰直角三角形D.以上答案都不正确\"}],\"width\":4716}]}", "Code": "noPermission", "Message": "You are not authorized to perform this operation." } ``` ## Error Codes Refer to the Error Center for more error codes. ## Change History | Change Time | Summary of Changes | Operation | |------------------|------------------------------------|----------------| | 2024-07-31 | OpenAPI input parameters changed | View Details | | 2021-08-17 | OpenAPI input parameters changed | View Details | ``` -------------------------------- ### Python - 调用文字识别 OCR 接口 Source: https://help.aliyun.com/zh/ocr/getting-started/getting-started 创建一个名为 `hello_ocr.py` 的Python文件,并将提供的代码复制进去以调用阿里云文字识别OCR接口。此代码示例(未在输入中提供完整内容)应包含SDK导入、客户端配置、请求构建及结果处理逻辑。 ```python # 请在此处粘贴您的 Python 代码 ``` -------------------------------- ### OCR GET Request Example (Java) Source: https://help.aliyun.com/zh/ocr/developer-reference/signature-method This Java code demonstrates how to make a GET request to the Aliyun OCR API, typically for retrieving results or status. ```APIDOC ## GET /ocr/result/{taskId} ### Description This endpoint retrieves the OCR processing result for a given task ID. ### Method GET ### Endpoint /ocr/result/{taskId} ### Parameters #### Path Parameters - **taskId** (string) - Required - The ID of the OCR task. #### Query Parameters None #### Request Body None ### Request Example ```java String url = "http://example.com/ocr/result/your_task_id"; String response = Demo.doGet(url); System.out.println(response); ``` ### Response #### Success Response (200) - **status** (string) - The status of the OCR task (e.g., "completed", "processing", "failed"). - **result** (object) - The OCR result if the task is completed. #### Response Example ```json { "status": "completed", "result": { "text": "Extracted text from the image." } } ``` ``` -------------------------------- ### Go: Install OCR API SDK Source: https://help.aliyun.com/zh/ocr/getting-started/use-process This command installs the Go SDK for Alibaba Cloud's OCR API version 20210707. Ensure you have Go version 1.10 or higher installed before running this command. This SDK is necessary for interacting with the OCR services from a Go application. ```bash go get github.com/alibabacloud-go/ocr-api-20210707/v3 ``` -------------------------------- ### GET /websites/help_aliyun_zh_ocr - Example OCR Response Source: https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizemedicaldevicemanagelicense This endpoint provides an example of a successful response from the Aliyun OCR service when processing a Chinese document, specifically a medical device business license. ```APIDOC ## GET /websites/help_aliyun_zh_ocr ### Description This endpoint returns an example JSON response for a successful OCR operation on a Chinese document. It includes extracted text, recognized key-value pairs, and information about detected figures within the document. ### Method GET ### Endpoint /websites/help_aliyun_zh_ocr ### Parameters None ### Request Example ```json { "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD00655", "Data": "{\t\"data\": { \t\t\"title\": \"中华人民共和国医疗器械经营企业许可证\", \t\t\"licenseNumber\": \"320541\", \t\t\"companyName\": \"宣城市成光科技有限公司\", \t\t\"businessType\": \"\", \t\t\"officeAddress\": \"\", \t\t\"businessScope\": \"第Ⅱ类:临床检验分析仪器(6840)、基础外科手术器械(6801)、口腔科设备及器具(6855)医用电子仪器设备(6821)、医用卫生材料及辅料(6864)、普通诊察设备(6820)、医用高分子材料及制品(6866)。\", \t\t\"businessAddress\": \"宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"warehouseAddress\": \"安徽省宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"issueDate\": \"2017年03月27日\", \t\t\"issueAuthority\": \"宣城市食品药品监督管理局\", \t\t\"legalRepresentative\": \"李巷\", \t\t\"responsiblePerson\": \"李巷\", \t\t\"qualityManager\": \"\", \t\t\"registeredAddress\": \"\", \t\t\"validToDate\": \"2022年03月26日\" \t}, \t\"figure\": [{ \t\t\"type\": \"round_stamp\", \t\t\"x\": 1017, \t\t\"y\": 702, \t\t\"w\": 140, \t\t\"h\": 144, \t\t\"box\": { \t\t\t\"x\": 1086, \t\t\t\"y\": 773, \t\t\"w\": 137, \t\t\"h\": 141, \t\t\"angle\": 0 \t }, \t\t\"points\": [{ \t\t\t\"x\": 1017, \t\t\"y\": 703 \t }, { \t\t\"x\": 1154, \t\t\"y\": 702 \t }, { \t\t\"x\": 1155, \t\t\"y\": 843 \t }, { \t\t\"x\": 1017, \t\t\"y\": 844 \t }] \t}, { \t\t\"type\": \"national_emblem\", \t\t\"x\": 650, \t\t\"y\": 34, \t\t\"w\": 152, \t\t\"h\": 152, \t\t\"box\": { \t\t\t\"x\": 725, \t\t\"y\": 109, \t\t\"w\": 149, \t\t\"h\": 149, \t\t\"angle\": -89 \t }, \t\t\"points\": [{ \t\t\"x\": 650, \t\t\"y\": 183 \t }, { \t\t\"x\": 651, \t\t\"y\": 34 \t }, { \t\t\"x\": 800, \t\t\"y\": 35 \t }, { \t\t\"x\": 799, \t\t\"y\": 184 \t }] \t}, { \t\t\"type\": \"blicense_title\", \t\t\"x\": 367, \t\t\"y\": 271, \t\t\"w\": 684, \t\t\"h\": 76, \t\t\"box\": { \t\t\t\"x\": 708, \t\t\"y\": 308, \t\t\"w\": 681, \t\t\"h\": 72, \t\t\"angle\": 0 \t }, \t\t\"points\": [{ \t\t\"x\": 367, \t\t\"y\": 273 \t }, { \t\t\"x\": 1049, \t\t\"y\": 271 \t }, { \t\t\"x\": 1049, \t\t\"y\": 344 \t }, { \t\t\"x\": 368, \t\t\"y\": 345 \t }] \t}], \t\"ftype\": 0, \t\"height\": 995, \t\"orgHeight\": 995, \t\"orgWidth\": 1417, \t\"prism_keyValueInfo\": [{ \t\t\"key\": \"title\", \t\t\"keyProb\": 100, \t\t\"value\": \"中华人民共和国医疗器械经营企业许可证\", \t\t\"valuePos\": [{ \t\t\t\"x\": 326, \t\t\"y\": 304 \t }, { \t\t\"x\": 328, \t\t\"y\": 178 \t }, { \t\t\"x\": 1016, \t\t\"y\": 189 \t }, { \t\t\"x\": 1014, \t\t\"y\": 315 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"licenseNumber\", \t\t\"keyProb\": 100, \t\t\"value\": \"320541\", \t\t\"valuePos\": [{ \t\t\t\"x\": 1106, \t\t\"y\": 332 \t }, { \t\t\"x\": 1106, \t\t\"y\": 352 \t }, { \t\t\"x\": 1033, \t\t\"y\": 352 \t }, { \t\t\"x\": 1033, \t\t\"y\": 332 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"companyName\", \t\t\"keyProb\": 100, \t\t\"value\": \"宣城市成光科技有限公司\", \t\t\"valuePos\": [{ \t\t\t\"x\": 566, \t\t\"y\": 380 \t }, { \t\t\"x\": 567, \t\t\"y\": 403 \t }, { \t\t\"x\": 363, \t\t\"y\": 405 \t }, { \t\t\"x\": 363, \t\t\"y\": 383 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"businessType\", \t\t\"keyProb\": 100, \t\t\"value\": \"\", \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"officeAddress\", \t\t\"keyProb\": 100, \t\t\"value\": \"\", \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"businessScope\", \t\t\"keyProb\": 100, \t\t\"value\": \"第Ⅱ类:临床检验分析仪器(6840)、基础外科手术器械(6801)、口腔科设备及器具(6855)医用电子仪器设备(6821)、医用卫生材料及辅料(6864)、普通诊察设备(6820)、医用高分子材料及制品(6866)。\", \t\t\"valuePos\": [{ \t\t\t\"x\": 901, \t\t\"y\": 394 \t }, { \t\t\"x\": 1234, \t\t\"y\": 394 \t }, { \t\t\"x\": 1234, \t\t\"y\": 549 \t }, { \t\t\"x\": 901, \t\t\"y\": 549 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"businessAddress\", \t\t\"keyProb\": 100, \t\t\"value\": \"宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"valuePos\": [{ \t\t\t\"x\": 772, \t\t\"y\": 426 \t }, { \t\t\"x\": 772, \t\t\"y\": 444 \t }, { \t\t\"x\": 363, \t\t\"y\": 446 \t }, { \t\t\"x\": 362, \t\t\"y\": 427 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"warehouseAddress\", \t\t\"keyProb\": 100, \t\t\"value\": \"安徽省宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"valuePos\": [{ \t\t\t\"x\": 363, \t\t\"y\": 584 \t }, { \t\t\"x\": 710, \t\t\"y\": 584 \t }, { \t\t\"x\": 710, \t\t\"y\": 637 \t }, { \t\t\"x\": 363, \t\t\"y\": 637 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"issueDate\", \t\t\"keyProb\": 100, \t\t\"value\": \"2017年03月27日\", \t\t\"valuePos\": [{ \t\t\t\"x\": 1047, \t\t\"y\": 793 \t }, { \t\t\"x\": 1047, \t\t\"y\": 810 \t }, { \t\t\"x\": 896, \t\t\"y\": 810 \t }, { \t\t\"x\": 896, \t\t\"y\": 793 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"issueAuthority\", \t\t\"keyProb\": 100, \t\t\"value\": \"宣城市食品药品监督管理局\", \t\t\"valuePos\": [{ \t\t\t\"x\": 892, \t\t\"y\": 746 \t }, { \t\t\"x\": 1153, \t\t\"y\": 745 \t }, { \t\t\"x\": 1153, \t\t\"y\": 770 \t }, { \t\t\"x\": 893, \t\t\"y\": 772 \t }], \t\t\"valuePro\"} }" } ``` ### Response #### Success Response (200) - **RequestId** (string) - The unique identifier for the request. - **Data** (string) - A JSON string containing the detailed OCR results, including extracted text, key-value pairs, and figure information. #### Response Example ```json { "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD00655", "Data": "{\t\"data\": { \t\t\"title\": \"中华人民共和国医疗器械经营企业许可证\", \t\t\"licenseNumber\": \"320541\", \t\t\"companyName\": \"宣城市成光科技有限公司\", \t\t\"businessType\": \"\", \t\t\"officeAddress\": \"\", \t\t\"businessScope\": \"第Ⅱ类:临床检验分析仪器(6840)、基础外科手术器械(6801)、口腔科设备及器具(6855)医用电子仪器设备(6821)、医用卫生材料及辅料(6864)、普通诊察设备(6820)、医用高分子材料及制品(6866)。\", \t\t\"businessAddress\": \"宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"warehouseAddress\": \"安徽省宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"issueDate\": \"2017年03月27日\", \t\t\"issueAuthority\": \"宣城市食品药品监督管理局\", \t\t\"legalRepresentative\": \"李巷\", \t\t\"responsiblePerson\": \"李巷\", \t\t\"qualityManager\": \"\", \t\t\"registeredAddress\": \"\", \t\t\"validToDate\": \"2022年03月26日\" \t}, \t\"figure\": [{ \t\t\"type\": \"round_stamp\", \t\t\"x\": 1017, \t\t\"y\": 702, \t\t\"w\": 140, \t\t\"h\": 144, \t\t\"box\": { \t\t\t\"x\": 1086, \t\t\"y\": 773, \t\t\"w\": 137, \t\t\"h\": 141, \t\t\"angle\": 0 \t }, \t\t\"points\": [{ \t\t\"x\": 1017, \t\t\"y\": 703 \t }, { \t\t\"x\": 1154, \t\t\"y\": 702 \t }, { \t\t\"x\": 1155, \t\t\"y\": 843 \t }, { \t\t\"x\": 1017, \t\t\"y\": 844 \t }] \t}, { \t\t\"type\": \"national_emblem\", \t\t\"x\": 650, \t\t\"y\": 34, \t\t\"w\": 152, \t\t\"h\": 152, \t\t\"box\": { \t\t\t\"x\": 725, \t\t\"y\": 109, \t\t\"w\": 149, \t\t\"h\": 149, \t\t\"angle\": -89 \t }, \t\t\"points\": [{ \t\t\"x\": 650, \t\t\"y\": 183 \t }, { \t\t\"x\": 651, \t\t\"y\": 34 \t }, { \t\t\"x\": 800, \t\t\"y\": 35 \t }, { \t\t\"x\": 799, \t\t\"y\": 184 \t }] \t}, { \t\t\"type\": \"blicense_title\", \t\t\"x\": 367, \t\t\"y\": 271, \t\t\"w\": 684, \t\t\"h\": 76, \t\t\"box\": { \t\t\t\"x\": 708, \t\t\"y\": 308, \t\t\"w\": 681, \t\t\"h\": 72, \t\t\"angle\": 0 \t }, \t\t\"points\": [{ \t\t\"x\": 367, \t\t\"y\": 273 \t }, { \t\t\"x\": 1049, \t\t\"y\": 271 \t }, { \t\t\"x\": 1049, \t\t\"y\": 344 \t }, { \t\t\"x\": 368, \t\t\"y\": 345 \t }] \t}], \t\"ftype\": 0, \t\"height\": 995, \t\"orgHeight\": 995, \t\"orgWidth\": 1417, \t\"prism_keyValueInfo\": [{ \t\t\"key\": \"title\", \t\t\"keyProb\": 100, \t\t\"value\": \"中华人民共和国医疗器械经营企业许可证\", \t\t\"valuePos\": [{ \t\t\t\"x\": 326, \t\t\"y\": 304 \t }, { \t\t\"x\": 328, \t\t\"y\": 178 \t }, { \t\t\"x\": 1016, \t\t\"y\": 189 \t }, { \t\t\"x\": 1014, \t\t\"y\": 315 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"licenseNumber\", \t\t\"keyProb\": 100, \t\t\"value\": \"320541\", \t\t\"valuePos\": [{ \t\t\t\"x\": 1106, \t\t\"y\": 332 \t }, { \t\t\"x\": 1106, \t\t\"y\": 352 \t }, { \t\t\"x\": 1033, \t\t\"y\": 352 \t }, { \t\t\"x\": 1033, \t\t\"y\": 332 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"companyName\", \t\t\"keyProb\": 100, \t\t\"value\": \"宣城市成光科技有限公司\", \t\t\"valuePos\": [{ \t\t\t\"x\": 566, \t\t\"y\": 380 \t }, { \t\t\"x\": 567, \t\t\"y\": 403 \t }, { \t\t\"x\": 363, \t\t\"y\": 405 \t }, { \t\t\"x\": 363, \t\t\"y\": 383 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"businessType\", \t\t\"keyProb\": 100, \t\t\"value\": \"\", \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"officeAddress\", \t\t\"keyProb\": 100, \t\t\"value\": \"\", \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"businessScope\", \t\t\"keyProb\": 100, \t\t\"value\": \"第Ⅱ类:临床检验分析仪器(6840)、基础外科手术器械(6801)、口腔科设备及器具(6855)医用电子仪器设备(6821)、医用卫生材料及辅料(6864)、普通诊察设备(6820)、医用高分子材料及制品(6866)。\", \t\t\"valuePos\": [{ \t\t\t\"x\": 901, \t\t\"y\": 394 \t }, { \t\t\"x\": 1234, \t\t\"y\": 394 \t }, { \t\t\"x\": 1234, \t\t\"y\": 549 \t }, { \t\t\"x\": 901, \t\t\"y\": 549 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"businessAddress\", \t\t\"keyProb\": 100, \t\t\"value\": \"宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"valuePos\": [{ \t\t\t\"x\": 772, \t\t\"y\": 426 \t }, { \t\t\"x\": 772, \t\t\"y\": 444 \t }, { \t\t\"x\": 363, \t\t\"y\": 446 \t }, { \t\t\"x\": 362, \t\t\"y\": 427 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"warehouseAddress\", \t\t\"keyProb\": 100, \t\t\"value\": \"安徽省宣城经济技术开发区水阳江大道以北、创业路以东(公寓式酒店)\", \t\t\"valuePos\": [{ \t\t\t\"x\": 363, \t\t\"y\": 584 \t }, { \t\t\"x\": 710, \t\t\"y\": 584 \t }, { \t\t\"x\": 710, \t\t\"y\": 637 \t }, { \t\t\"x\": 363, \t\t\"y\": 637 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"issueDate\", \t\t\"keyProb\": 100, \t\t\"value\": \"2017年03月27日\", \t\t\"valuePos\": [{ \t\t\t\"x\": 1047, \t\t\"y\": 793 \t }, { \t\t\"x\": 1047, \t\t\"y\": 810 \t }, { \t\t\"x\": 896, \t\t\"y\": 810 \t }, { \t\t\"x\": 896, \t\t\"y\": 793 \t }], \t\t\"valueProb\": 100 \t}, { \t\t\"key\": \"issueAuthority\", \t\t\"keyProb\": 100, \t\t\"value\": \"宣城市食品药品监督管理局\", \t\t\"valuePos\": [{ \t\t\t\"x\": 892, \t\t\"y\": 746 \t }, { \t\t\"x\": 1153, \t\t\"y\": 745 \t }, { \t\t\"x\": 1153, \t\t\"y\": 770 \t }, { \t\t\"x\": 893, \t\t\"y\": 772 \t }], \t\t\"valuePro\"} }" } ``` ``` -------------------------------- ### Python - 创建和激活虚拟环境 Source: https://help.aliyun.com/zh/ocr/getting-started/getting-started 此命令用于创建一个名为".venv"的Python虚拟环境,以隔离项目依赖。成功创建后,根据您的操作系统(Windows、macOS或Linux)运行相应的激活命令来启用虚拟环境。 ```bash # 如果运行失败,您可以将python替换成python3再运行 python -m venv .venv ``` ```bash # Windows 系统激活命令 .venv\Scripts\activate ``` ```bash # macOS 或 Linux 系统激活命令 source .venv/bin/activate ``` -------------------------------- ### Check Java Installation (Shell) Source: https://help.aliyun.com/zh/ocr/developer-reference/sdk-overview Checks if Java is installed on the system and displays its version. Requires Java 8 or higher. The output format typically starts with 'openjdk version "X.Y.Z" ...' or 'java version "X.Y.Z" ...'. ```shell java -version ``` -------------------------------- ### RecognizeTradeMarkCertification API Request (Node.js) Source: https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizetrademarkcertification Example of how to call the RecognizeTradeMarkCertification API using the Aliyun SDK for Node.js. This snippet illustrates setting up the client with your credentials and region, sending the image URL, and logging the response. Ensure you have the Aliyun SDK for Node.js installed. ```javascript const Ocr20191230 = require('@alicloud/ocr-20191230'); const openApiSdk = require('@alicloud/openapi-client-sdk'); async function recognizeTradeMarkCertification(client) { const request = new Ocr20191230.RecognizeTradeMarkCertificationRequest({ imageURL: 'https://img.alicdn.com/tfs/TB1SZiGdfb2gK0jSZK9XXaEgFXa-1654-2340.png' // Replace with your image URL }); try { const response = await client.recognizeTradeMarkCertification(request); console.log('RequestId:', response.body.requestId); console.log('Data:', response.body.data); // Process the response data as needed } catch (error) { console.error('Error calling API:', error); } } // Replace with your actual AccessKey ID and Secret openApiSdk.default(Object.assign({ accessKeyId: 'YOUR_ACCESS_KEY_ID', accessKeySecret: 'YOUR_ACCESS_KEY_SECRET', // Replace with your actual region ID endpoint: 'ocr.cn-hangzhou.aliyuncs.com', apiVersion: '2019-12-30' })) .then(client => { recognizeTradeMarkCertification(client); }) .catch(err => { console.error('SDK initialization error:', err); }); ``` -------------------------------- ### RecognizeTradeMarkCertification API Request (Python) Source: https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizetrademarkcertification Example of how to call the RecognizeTradeMarkCertification API using the Aliyun SDK for Python. This snippet shows how to initialize the client, set the image URL for recognition, and print the response. Make sure the Aliyun SDK for Python is installed. ```python from alibabacloud_ocr_20191230.client import Client as OcrClient from alibabacloud_ocr_20191230.models import RecognizeTradeMarkCertificationRequest from alibabacloud_tea_openapi.models import Config # Replace with your actual region ID config = Config(region_id="cn-hangzhou") client = OcrClient(config) request = RecognizeTradeMarkCertificationRequest( image_url="https://img.alicdn.com/tfs/TB1SZiGdfb2gK0jSZK9XXaEgFXa-1654-2340.png" # Replace with your image URL ) try: response = client.recognize_trade_mark_certification(request) print(f"RequestId: {response.body.request_id}") print(f"Data: {response.body.data}") # Process the response data as needed except Exception as e: print(f"Error calling API: {e}") ``` -------------------------------- ### Add Permanent Environment Variables to .bashrc for Alibaba Cloud OCR Source: https://help.aliyun.com/zh/ocr/getting-started/getting-started Appends Alibaba Cloud Access Key ID and Secret environment variables to the ~/.bashrc file for permanent availability across new sessions. Includes instructions for manual editing using nano and applying changes with `source`. ```shell # <access_key_id>需替换为您的AccessKey ID,<access_key_secret>替换为您的AccessKey Secret。 echo "export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>" >> ~/.bashrc echo "export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>" >> ~/.bashrc source ~/.bashrc echo $ALIBABA_CLOUD_ACCESS_KEY_ID echo $ALIBABA_CLOUD_ACCESS_KEY_SECRET ``` ```shell # <access_key_id>需替换为您的AccessKey ID,<access_key_secret>替换为您的AccessKey Secret。 export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id> export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret> ``` -------------------------------- ### Python: Create and Activate Virtual Environment Source: https://help.aliyun.com/zh/ocr/getting-started/use-process These commands guide you through creating and activating a Python virtual environment named '.venv'. This is an optional step to prevent dependency conflicts with other projects. It includes commands for creating the environment and activating it on Windows, macOS, or Linux systems. ```bash # 如果运行失败,您可以将python替换成python3再运行 python -m venv .venv ``` ```bash .venv\Scripts\activate ``` ```bash source .venv/bin/activate ``` -------------------------------- ### Add Permanent Environment Variables to .bash_profile for Alibaba Cloud OCR Source: https://help.aliyun.com/zh/ocr/getting-started/getting-started Appends Alibaba Cloud Access Key ID and Secret environment variables to the ~/.bash_profile file for permanent availability across sessions. Includes instructions for manual editing using nano and applying changes with `source`. ```shell # <access_key_id>需替换为您的AccessKey ID,<access_key_secret>替换为您的AccessKey Secret。 echo "export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>" >> ~/.bash_profile echo "export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>" >> ~/.bash_profile source ~/.bash_profile echo $ALIBABA_CLOUD_ACCESS_KEY_ID echo $ALIBABA_CLOUD_ACCESS_KEY_SECRET ``` ```shell # <access_key_id>需替换为您的AccessKey ID,<access_key_secret>替换为您的AccessKey Secret。 export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id> export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret> ``` -------------------------------- ### Python: Create OCR API Client Source: https://help.aliyun.com/zh/ocr/getting-started/getting-started This snippet shows how to create an OCR API client instance using environment variables for authentication. It configures the client with access key ID, secret, and the API endpoint. Ensure the environment variables `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` are set. ```python import os from alibabacloud_ocr_api20210707.client import Client as ocr_api20210707Client from alibabacloud_tea_openapi import models as open_api_models from alibabacloud_tea_util import models as util_models class Sample: @staticmethod def create_client() -> ocr_api20210707Client: config = open_api_models.Config( # 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID.、 access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'], # 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET.、 access_key_secret=os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] ) # 默认公网接入地址为"ocr-api.cn-hangzhou.aliyuncs.com",若您需要使用vpc域名访问,请确保您的ecs建立在杭州region,vpc接入地址为"ocr-api-vpc.cn-hangzhou.aliyuncs.com" config.endpoint = f'ocr-api.cn-hangzhou.aliyuncs.com' return ocr_api20210707Client(config) ```