# Driving license identification

Debugging Tools

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: drivingocr

OCR Identification of Motor Vehicle License Information

# 1. How to call

# HTTPS calls

POST https://api.weixin.qq.com/cv/ocr/driving?access_token=ACCESS_TOKEN&img_url=IMG_URL

# Cloud Calls

  • Call method: ocr.drivingLicense

  • 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 NametypeRequired to fill inExampleIntroductions
access_tokenstringyesACCESS_TOCKENInterface invocation credentials, using access_token , authorizer_access_token
img_urlstringnoENCODE_URLTo detect the image url, pass this without passing the img parameter.

# Request BodyRequest Payload

Parameter NametypeRequired to fill inIntroductions
imgformdatayesForm-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 NametypeIntroductions
errcodenumberError code
errmsgstringError message
plate_numstringThe license plate number
vehicle_typestringType of vehicle
ownerstringAll of us
addrstringaddress
use_characterstringProperties of use
modelstringBrand Model
vinstringVehicle identification code
engine_numstringEngine number
register_datestringDate of registration
issue_datestringDate of issue
plate_num_bstringThe license plate number
recordstringlicense plate
passengers_numstringAuthorized loading capacity
total_qualitystringTotal quality
prepare_qualitystringSpare quality

# 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,Used together with Weixin Mini Program photography, album selection, etc., it can complete the process of photo collection, upload, identification, information return, etc. for business scenarios that require physical cards or certificates such as ID card or bank card to collect photos or text information.
  • 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/driving?access_token=ACCESS_TOCKEN"

Return an example

{
    "errcode": 0,
    "errmsg": "ok",
    "plate_num": "粤xxxxx", //车牌号码
    "vehicle_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" //整备质量,
    "overall_size": "4582x1795x1458mm" //外廓尺寸,
    "card_position_front": {//卡片正面位置(检测到卡片正面才会返回)
        "pos": {
            "left_top": {
                "x": 119, 
                "y": 2925
            }, 
            "right_top": {
                "x": 1435, 
                "y": 2887
            }, 
            "right_bottom": {
                "x": 1435, 
                "y": 3793
            }, 
            "left_bottom": {
                "x": 119, 
                "y": 3831
            }
        }
    }, 
    "card_position_back": {//卡片反面位置(检测到卡片反面才会返回)
        "pos": {
            "left_top": {
                "x": 1523, 
                "y": 2849
            }, 
            "right_top": {
                "x": 2898, 
                "y": 2887
            }, 
            "right_bottom": {
                "x": 2927, 
                "y": 3831
            }, 
            "left_bottom": {
                "x": 1523, 
                "y": 3831
            }
        }
    }, 
    "img_size": {//图片大小
        "w": 3120, 
        "h": 4208
    }
}

Example Requests

curl https://api.weixin.qq.com/cv/ocr/driving?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN

Return an example

{
    "errcode": 0,
    "errmsg": "ok",
    "plate_num": "粤xxxxx", //车牌号码
    "vehicle_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" //整备质量,
    "overall_size": "4582x1795x1458mm" //外廓尺寸,
    "card_position_front": {//卡片正面位置(检测到卡片正面才会返回)
        "pos": {
            "left_top": {
                "x": 119, 
                "y": 2925
            }, 
            "right_top": {
                "x": 1435, 
                "y": 2887
            }, 
            "right_bottom": {
                "x": 1435, 
                "y": 3793
            }, 
            "left_bottom": {
                "x": 119, 
                "y": 3831
            }
        }
    }, 
    "card_position_back": {//卡片反面位置(检测到卡片反面才会返回)
        "pos": {
            "left_top": {
                "x": 1523, 
                "y": 2849
            }, 
            "right_top": {
                "x": 2898, 
                "y": 2887
            }, 
            "right_bottom": {
                "x": 2927, 
                "y": 3831
            }, 
            "left_bottom": {
                "x": 1523, 
                "y": 3831
            }
        }
    }, 
    "img_size": {//图片大小
        "w": 3120, 
        "h": 4208
    }
}

# 5.3 Cloud function call example

Example Requests

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.ocr.vehicleLicense({
        "type": 'photo',
        "imgUrl": 'ENCODE_URL'
      })
    return result
  } catch (err) {
    return err
  }
}

Return an example

{
  "vehicleType": "小型普通客⻋",
  "owner": "东莞市xxxxx机械厂",
  "addr": "广东省东莞市xxxxx号",
  "useCharacter": "非营运",
  "model": "江淮牌HFCxxxxxxx",
  "vin": "LJ166xxxxxxxx51",
  "engineNum": "J3xxxxx3",
  "registerDate": "2018-07-06",
  "issueDate": "2018-07-01",
  "plateNumB": "粤xxxxx",
  "record": "441xxxxxx3",
  "passengersNum": "7人",
  "totalQuality": "2700kg",
  "prepareQuality": "1995kg"
}

# 6. Error code

The following is a list of error codes for this interface, other error codes can refer to General error codes

Error codeError DescriptionSolutions
-1system errorThe system is busy, so the developer is asked to try again in a few minutes.
40001invalid credential  access_token isinvalid or not latestAppSecret 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
101000invalid image url
101003not enough market quota

# 7. Scope of application

How this interface can be invoked under different account types:
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;