May 20, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0
This interface provides OCR identification based on a small program
How to call:
POST https://api.weixin.qq.com/cv/ocr/driving?type=MODE&img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
type | string | Is | Picture recognition mode, photo (photo mode) or scan (scan mode) | |
img_url | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | string | Error code |
errmsg | string | The error message |
vehicle_type | string | The type of vehicle |
owner | string | All of them |
addr | string | Address |
use_character | string | The nature of the use |
model | string | Brand model |
Vin | string | Vehicle identification generation |
engine_num | string | Engine number |
register_date | string | The date of registration |
issue_date | string | The date of issue of the certificate |
plate_num_b | string | License plate number |
record | string | Plate |
passengers_num | string | Approved capacity |
total_quality | string | Total quality |
totalprepare_quality_quality | string | The quality of the preparation |
Interface limits the certified subscription number, service number, enterprise number, and applet during the internal test, and the number of times is limited to 500 times / day.
Using Tips this interface for the background interface, can be based on its own business hosting situation, with small programs of photography, photo selection, etc. together, you can complete the ID photo collection, upload, identification, information return and other processes, for the need to be based on identity cards, bank cards and other physical cards or certificates, collection of photos or text information and other business scenarios.
Image caption File size limit: less than 2M
Images support the use of img parameters for real-time upload, but also img_url parameters to transmit picture addresses, by WeChat background download pictures to identify. There are two types of type
Take a picture sample
Example 1:
curl https://api.weixin.qq.com/cv/ocr/driving?type=photo&img_url= ENCODE_URL&access_token=ACCESS_TOCKEN
Example 2:
curl -F ‘[email protected]’“https://api.weixin.qq.com/cv/ocr/driving?type=photo&access_token=ACCESS_TOCKEN”
{
"vhicle_type": "小型普通客⻋",
"owner": "东莞市xxxxx机械厂",
"addr": "广东省东莞市xxxxx号",
"use_character": "非营运",
"model": "江淮牌HFCxxxxxxx",
"vin": "LJ166xxxxxxxx51",
"engine_num": "J3xxxxx3",
"register_date": "2018-07-06",
"issue_date": "2018-07-01",
"plate_num_b": "粤xxxxx",
"record": "441xxxxxx3",
"passengers_num": "7人",
"total_quality": "2700kg",
"prepare_quality": "1995kg"
}
Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.
openapi.ocr.vehicleLicense
Permissions for the ocr.vehicleLicense API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
type | string | Is | Picture recognition mode, photo (photo mode) or scan (scan mode) | |
imgUrl | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The structure of img
Property | Type | The default | Required | Description |
---|---|---|---|---|
contentType | string | Is | Data type, incoming MIME Type | |
value | Buffer | Is | File Buffer |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
vehicleType | string | The type of vehicle |
owner | string | All of them |
addr | string | Address |
useCharacter | string | The nature of the use |
model | string | Brand model |
Vin | string | Vehicle identification generation |
engineNum | string | Engine number |
registerDate | string | The date of registration |
issueDate | string | The date of issue of the certificate |
plateNumB | string | License plate number |
record | string | Plate |
passengersNum | string | Approved capacity |
totalQuality | string | Total quality |
totalprepareQualityQuality | string | The quality of the preparation |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|
Interface Limits Subscription numbers, service numbers, enterprise numbers, and small programs that have been certified during the internal test can be called directly, with a limit of 500 times per day.
Using Tips this interface for the background interface, can be based on its own business hosting situation, with small programs of photography, photo selection, etc. together, you can complete the ID photo collection, upload, identification, information return and other processes, for the need to be based on identity cards, bank cards and other physical cards or certificates, collection of photos or text information and other business scenarios.
Image caption File size limit: less than 2M
Images support the use of img parameters for real-time upload, but also img_url parameters to transmit picture addresses, by WeChat background download pictures to identify. There are two types of type
Take a picture sample
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.ocr.vehicleLicense({
type: 'photo',
imgUrl: 'ENCODE_URL'
})
return result
} catch (err) {
return err
}
}
Or
// cloud = require('wx-server-sdk')
// ...
// 方法返回 Promise
cloud.openapi.ocr.vehicleLicense({
type: 'photo',
img: {
contentType: 'image/png',
value: Buffer
}
})
{
"vhicle_type": "小型普通客⻋",
"owner": "东莞市xxxxx机械厂",
"addr": "广东省东莞市xxxxx号",
"use_character": "非营运",
"model": "江淮牌HFCxxxxxxx",
"vin": "LJ166xxxxxxxx51",
"engine_num": "J3xxxxx3",
"register_date": "2018-07-06",
"issue_date": "2018-07-01",
"plate_num_b": "粤xxxxx",
"record": "441xxxxxx3",
"passengers_num": "7人",
"total_quality": "2700kg",
"prepare_quality": "1995kg"
}