codecamp

百度智能小程序 识别机动车行驶证关键字段

swan.ai.ocrVehicleLicense

解释 :对机动车行驶证正本所有关键字段进行识别。

方法参数

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 车辆类型

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

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

示例



图片示例

代码示例

Page({
    ocrVehicleLicense() {
        swan.chooseImage({
            success: res => {
                let image = res.tempFilePaths[0];
                // AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误
                let host = swan.getSystemInfoSync().host;
                if (host === 'baiduboxapp') {
                    swan.ai.ocrVehicleLicense({
                        image, // 暂不支持识别网络图片
                        detect_direction: true,
                        accuracy: normal
                        success: res => {
                            console.log('ocrVehicleLicense res', res.words_result);
                        },
                        fail: err => {
                            console.log('ocrVehicleLicense err', err);
                        }
                    });
                }
                else {
                    swan.showToast({
                        title: '此api目前仅可在百度App上使用',
                        icon: 'none'
                    });
                }
            }
        })
    }
});

返回值示例

{
    "log_id": $log_id,
    "direction": 0,
    "words_result_num": 10,
    "words_result": {
        "品牌型号": {
            "words": "保时捷GT37182RUCRE"
        },
        "发证日期": {
            "words": "20160104"
        },
        "使用性质": {
            "words": "非营运"
        },
        "发动机号码": {
            "words": "20832"
        },
        "号牌号码": {
            "words": "苏A001"
        },
        "所有人": {
            "words": "圆圆"
        },
        "住址": {
            "words": "南京市江宁区弘景大道"
        },
        "注册日期": {
            "words": "20160104"
        },
        "车辆识别代号": {
            "words": "HCE58"
        },
        "车辆类型": {
            "words": "小型轿车"
        }
    }
}
}


百度智能小程序 识别机动车驾驶证
百度智能小程序 运用深度学习技术
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

百度智能小程序开发文档

百度智能小程序 组件

百度智能小程序 地图

百度智能小程序 画布

百度智能小程序 API

百度智能小程序 界面

百度智能小程序 关注小程序引导组件

百度智能小程序 自定义组件

百度智能小程序 媒体

百度智能小程序 设备

百度智能小程序 拨打电话

百度智能小程序 内存警报

百度智能小程序 手机联系人

百度智能小程序 用户截屏事件

百度智能小程序 第三方平台

百度智能小程序 开放接口

百度智能小程序 百度收银支付

百度智能小程序 分包预下载

百度智能小程序 数据分析

百度智能小程序 服务端

百度智能小程序 云开发

百度智能小程序 初始化

百度智能小程序 云函数

百度智能小程序 服务端初始化

百度智能小程序 服务器获取上下文

百度智能小程序 服务端云函数

百度智能小程序 开发教程

百度智能小程序 功能开发

百度智能小程序 基本原理

百度智能小程序 小程序自动化

百度智能小程序 视频教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }