# Universal print identification
Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide
Interface English name: commocr
This interface is used to identify universal print
# 1. How to call
# HTTPS calls
POST https://api.weixin.qq.com/cv/ocr/comm?access_token=ACCESS_TOKEN&img_url=IMG_URL
# Cloud Calls
Call method: ocr.printedText
The input and exit parameters are the same as the HTTPS call, which can be called in the cloud call documentation
# Third party invocation
This interface supports Third Party Platform generation business call.
The permission set to which this interface belongs is id: 117
When a service provider is authorized by one of the permissions set, it can call on behalf of the merchant by using authorizer_access_token , which can be viewed in the third-party call documentation.
# 2. Request parameters
# Query parametersQuery String parameters
Parameter Name | type | Required to fill in | Example | Introductions |
---|---|---|---|---|
access_token | string | yes | ACCESS_TOCKEN | Interface invocation credentials, using access_token , authorizer_access_token |
img_url | string | no | ENCODE_URL | To detect the image url, pass this without passing the img parameter. |
# Request BodyRequest Payload
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
img | formdata | no | Form-data in the media file identification, filename, filelength, content-type and other information, you do not need to pass this img_url. |
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
errcode | number | Error code |
errmsg | string | Error Description |
items | objarray | Identification results |
img_size | object | Image size |
# Res.items(Array)Object Payload
Identification results
Parameter Name | type | Introductions |
---|---|---|
pos | object | Location Information |
# Res.img_sizeObject Payload
Image size
Parameter Name | type | Introductions |
---|---|---|
w | number | width |
h | number | height |
# Res.items(Array).posObject Payload
Location Information
Parameter Name | type | Introductions |
---|---|---|
left_top | object | Position in the upper left corner |
right_top | object | Position in the top right |
right_bottom | object | Position in the lower right |
left_bottom | object | Position in the lower left corner |
# Res.items(Array).pos.left_topObject Payload
Position in the upper left corner
Parameter Name | type | Introductions |
---|---|---|
x | number | X-coordinate |
y | number | Y-coordinate |
# Res.items(Array).pos.right_topObject Payload
Position in the top right
Parameter Name | type | Introductions |
---|---|---|
x | number | X-coordinate |
y | number | Y-coordinate |
# Res.items(Array).pos.right_bottomObject Payload
Position in the lower right
Parameter Name | type | Introductions |
---|---|---|
x | number | X-coordinate |
y | number | Y-coordinate |
# Res.items(Array).pos.left_bottomObject Payload
Position in the lower left corner
Parameter Name | type | Introductions |
---|---|---|
x | number | X-coordinate |
y | number | Y-coordinate |
# 4. Note
- Support for authenticated subscription number, Service Account, Weixin Mini Program, Service Account can be directly called, the number is limited to 100 times / day.If there is a higher amount of call demand, you can go to service platform for purchase.
- Tips This interface is used as the background interface, which can be based on its own business carrying situation,When used together with Weixin Mini Program photography, album selection, etc., it can complete the collection, upload, identification, information return, etc. of ID card photos, for business scenarios that require the collection of photos or text information based on physical cards or certificates such as ID card or bank card.
- Image caption File size limit: less than 2 M
- Image support using img parameter real-time upload, also support using img_url parameter transfer image address, by WeChat background download image recognition.There are two types of type
# 5. Code examples
# 5.1 Request to upload a file
Example Requests
curl -F 'img=@test.jpg' "https://api.weixin.qq.com/cv/ocr/comm?access_token=ACCESS_TOCKEN"
Return an example
{
"errcode": 0,
"errmsg": "ok",
"items": [ //识别结果
{
"text": "腾讯",
"pos": {
"left_top": {
"x": 575,
"y": 519
},
"right_top": {
"x": 744,
"y": 519
},
"right_bottom": {
"x": 744,
"y": 532
},
"left_bottom": {
"x": 573,
"y": 532
}
}
},
{
"text": "微信团队",
"pos": {
"left_top": {
"x": 670,
"y": 516
},
"right_top": {
"x": 762,
"y": 517
},
"right_bottom": {
"x": 762,
"y": 532
},
"left_bottom": {
"x": 670,
"y": 531
}
}
}
],
"img_size": { //图片大小
"w": 1280,
"h": 720
}
}
# 5.2 Request for an upload link
Example Requests
curl "https://api.weixin.qq.com/cv/ocr/comm?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN"
Return an example
{
"errcode": 0,
"errmsg": "ok",
"items": [ //识别结果
{
"text": "腾讯",
"pos": {
"left_top": {
"x": 575,
"y": 519
},
"right_top": {
"x": 744,
"y": 519
},
"right_bottom": {
"x": 744,
"y": 532
},
"left_bottom": {
"x": 573,
"y": 532
}
}
},
{
"text": "微信团队",
"pos": {
"left_top": {
"x": 670,
"y": 516
},
"right_top": {
"x": 762,
"y": 517
},
"right_bottom": {
"x": 762,
"y": 532
},
"left_bottom": {
"x": 670,
"y": 531
}
}
}
],
"img_size": { //图片大小
"w": 1280,
"h": 720
}
}
# 6. Error code
The following is a list of error codes for this interface, other error codes can refer to General error codes
Error code | Error Description | Solutions |
---|---|---|
-1 | system error | The system is busy, so the developer is asked to try again in a few minutes. |
40001 | invalid credential access_token isinvalid or not latest | AppSecret error while getting access_token, or access_token is invalid.Developers should check that AppSecret is correct, or that they are calling interfaces for the appropriate Official Account |
101000 | invalid image url | |
101002 | decode image failed | Image size over limit, resp_type = 0: 2MB, resp_type = 1: 10MB |
101003 | not enough market quota |
# 7. Scope of application
Weixin Mini Program | Official Account | Service Account |
---|---|---|
✔ | Certification only | Certification only |
- ✔: The account can call this interface
- Authentication only: means that only authenticated accounts are allowed to be invoked by the enterprise entity, and accounts that are not authenticated or do not support authentication cannot be invoked.
- Other account types that are not expressly stated may not be called on this interface without special instructions;