车牌识别

[!TIP|labelVisibility:hidden|iconVisibility:hidden] navigator.bdlicenseplate.licenseplate(success, error,options )

支持平台:

  • Android
  • iOS

参数说明

参数 类型 必填 说明
success Function 成功回调函数
error Function 失败回调函数
options Object 数据对象

success函数会返回一个json字符串,识别数据扫描结果信息:

  • result(对象) -- 车牌识别返回的所有数据,数据参考:https://ai.baidu.com/docs#/OCR-API/9bcb645d
  • message(对象) -- 车牌识别数据,其属性包含以下一项或多项:
    • number(String) -- 车牌号
    • imagePath(String) -- 扫描的图片存储路径

error函数会返回一个字符串,扫描错误的相关信息,错误码参考https://ai.baidu.com/docs#/OCR-API/58fd45dd

options参数为一个对象,其属性包含以下一项或多项:

  • imgPath(整形/ 可选) -- 扫描的图片存储路径,0:相册,1:项目路径,默认相册
  • imgType(整形/ 可选) -- )扫描的图片类型,0:.jpg格式,1:.png格式,默认jpg

示例代码

// 引用js
<script src='supconit://hcmobile.js'></script>
<script>
    // 监听’deviceready‘事件
    document.addEventListener('deviceready', onDeviceReady, false)
    function onDeviceReady(){
        navigator.bdlicenseplate.licenseplate(function (success) {
            alert(success);
        },function (error) {
            alert(error);
        },{'imgPath':1,'imgType':0});
    }
</script>

响应示例代码:

{
    "result": {
        "log_id": 000,
        "words_result": {
            "probability": [
                0.90070027112,
                0.90050041675,
                0.90232253074,
                0.901904642581,
                0.901400983333,
                0.900927841663,
                0.900532901287
            ],
            "number": "123",
            "vertexes_location": [
                {
                    "y": 458,
                    "x": 55
                },
                {
                    "y": 472,
                    "x": 522
                },
                {
                    "y": 615,
                    "x": 517
                },
                {
                    "y": 601,
                    "x": 51
                }
            ],
            "color": "blue"
        }
    },
    "message": {
        "number": "123",
        "imagePath": "cdvfile://localhost/cache/1578988384000.jpg"
    }
}

results matching ""

    No results matching ""