后浪云百度小程序教程:swan.ai.ocrVehicleLicense

  • swan.ai.ocrVehicleLicense
    • 方法参数
      • object 参数说明
      • success 返回参数说明
      • words_result 返回值说明
      • 品牌型号、发证日期、使用性质、发动机号码、号牌号码、所有人、住址、注册日期、车辆识别代号、车辆类型 返回值说明
    • 示例
      • 图片示例
      • 代码示例
      • 返回值示例

    swan.ai.ocrVehicleLicense

    解释 :对机动车行驶证正本所有关键字段进行识别。
    Web 态说明:受宿主环境限制,Web 态暂不支持 AI 能力相关接口。在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。

    方法参数

    Object object

    object 参数说明

    属性名类型必填默认值说明

    image

    String

    -

    图像资源地址

    detect_direction

    Boolean

    是否检测图像旋转,可检验图像的选装方向和旋转角度。
    · true:检测旋转角度并矫正识别。针对摆放情况不可控制的情况建议本参数置为 true;
    · false:不检测旋转角度,默认不检测

    accuracy

    String

    -

    normal 使用快速服务,1200ms 左右时延;缺省或其它值使用高精度服务,1600ms 左右时延

    success

    Function

    接口调用成功的回调函数

    fail

    Function

    接口调用失败的回调函数

    complete

    Function

    接口调用结束的回调函数(调用成功、失败都会执行)

    success 返回参数说明

    参数类型说明

    log_id

    Number

    唯一的 log id ,用于问题定位

    words_result_num

    Number

    识别结果数,表示 words_result 的元素个数

    words_result

    Object

    识别结果

    words_result 返回值说明

    参数名参数类型说明
    品牌型号Object品牌型号
    发证日期Object发证日期
    使用性质Object使用性质
    发动机号码Object发动机号码
    号牌号码Object号牌号码
    所有人Object所有人
    住址Object住址
    注册日期Object注册日期
    车辆识别代号Object车辆识别代号
    车辆类型Object车辆类型

    品牌型号、发证日期、使用性质、发动机号码、号牌号码、所有人、住址、注册日期、车辆识别代号、车辆类型 返回值说明

    参数名参数类型说明
    wordsString识别结果字符串

    示例

    跳转编辑工具

    在开发者工具中打开

    在 WEB IDE 中打开

    扫码体验

    代码示例

    请使用百度APP扫码

    图片示例

    代码示例

    • JS
     
     
     
    1. Page({
    2. ocrVehicleLicense() {
    3. swan.chooseImage({
    4. success: res => {
    5. let image = res.tempFilePaths[0];
    6. // AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误
    7. let host = swan.getSystemInfoSync().host;
    8. if (host === 'baiduboxapp') {
    9. swan.ai.ocrVehicleLicense({
    10. // 暂不支持识别网络图片
    11. image,
    12. detect_direction: true,
    13. accuracy: normal
    14. success: res => {
    15. console.log('ocrVehicleLicense res', res.words_result);
    16. },
    17. fail: err => {
    18. console.log('ocrVehicleLicense err', err);
    19. }
    20. });
    21. }
    22. else {
    23. swan.showToast({
    24. title: '此api目前仅可在百度App上使用',
    25. icon: 'none'
    26. });
    27. }
    28. }
    29. })
    30. }
    31. });

    返回值示例

    • JSON
     
     
     
    1. {
    2. "log_id": $log_id,
    3. "direction": 0,
    4. "words_result_num": 10,
    5. "words_result": {
    6. "品牌型号": {
    7. "words": "保时捷GT37182RUCRE"
    8. },
    9. "发证日期": {
    10. "words": "20160104"
    11. },
    12. "使用性质": {
    13. "words": "非营运"
    14. },
    15. "发动机号码": {
    16. "words": "20832"
    17. },
    18. "号牌号码": {
    19. "words": "苏A001"
    20. },
    21. "所有人": {
    22. "words": "圆圆"
    23. },
    24. "住址": {
    25. "words": "南京市江宁区弘景大道"
    26. },
    27. "注册日期": {
    28. "words": "20160104"
    29. },
    30. "车辆识别代号": {
    31. "words": "HCE58"
    32. },
    33. "车辆类型": {
    34. "words": "小型轿车"
    35. }
    36. }
    37. }
    38. }
    THE END