一枚假程序猿
一枚假程序猿
  • 发布:2023-01-04 14:50
  • 更新:2024-03-06 12:48
  • 阅读:273

UniAPP车牌实时离线扫描识别

分类:uni-app

插件说明

UniAPP车牌实时离线扫描识别(Android平台)

标签:车牌实时识别 车牌离线识别 车牌实时扫描 车牌离线扫描 车牌实时离线识别 车牌实时离线扫描

特点:

  • 1、使用方便,引入即可;
  • 2、响应快速,原生体验;
  • 3、完全离线,无需联网;
  • 4、插件包体积小,不占用云打包资源(参考后边压缩体积教程);
  • 5、完全独立,不依赖任何第三方SDK(目前发现很多依赖百度等第三方SDK,需要单独进行购买第三方服务或者授权,此插件承诺终身使用);
  • 6、返回结果内容丰富,支持:车牌号车牌颜色车牌抓拍图片
  • 7、支持车牌类型齐全;
  • 8、支持离线打包;
  • 9、可进行定制;

效果:

车牌实时识别
车牌实时识别-结果

支持车牌:

序号 车牌类型 是否支持
1 单行蓝牌
2 单行黄牌
3 新能源车牌
4 白色警用车牌
5 教练车牌
6 武警车牌
7 双层黄牌
8 双层武警
9 使馆车牌
10 港澳牌车
11 双层农用车牌
12 民航车牌
13 摩托车牌
14 危险品车牌

平台兼容性

平台 是否支持 支持版本 支持CPU类型
Android 5.0 - 13.0 + armeabi-v7a、arm64-v8a、x86
iOS ×

原生插件通用使用流程:

  • 1、购买插件,选择该插件绑定的项目;
  • 2、在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加;
  • 3、根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能;
  • 4、打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试;
  • 5、开发完毕后正式云打包;

目前插件市场所有付费原生插件均不支持离线打包,此插件支持离线打包!!!

  • Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
  • iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择;

使用说明

参考官网原生插件使用:
https://nativesupport.dcloud.net.cn/NativePlugin/use/use.html

使用步骤

  • 1、解压插件:

    解压插件zip包到uniapp项目目录nativePlugins中;

  • 2、引用插件:

    1) 点击manifest.json 进行配置;
    2) 选择指定的本地插件(自动识别):

  • 3、使用插件:

// 一行代码引用  
var plateModule = uni.requireNativePlugin("PlateModule")  

// 调用识别程序  
plateModule.startPlate(  
    {  
        'accuracy': 0.80, // 识别准确率(取值范围:0.0-1.0。准确率大于该值才返回结果,值越大识别越准确但也会越慢,需要测试出来最适合自己的准确率)  
        'quality': 80, // 图像压缩率(取值范围:0-100。 0:压缩100%,100:不压缩)  
        'showText': true // 是否显示提示文字  
    },  
    (ret) => {  
        console.log("showLPR result : ", ret);  
        modal.toast({  
            message: ret,  
            duration: 1.5  
        });  
        //解析  
        this.success = true;  
        if (ret.number) {  
            this.number = ret.number;  
        }  
        if (ret.color) {  
            this.color = ret.color;  
        }  
        if (ret.image) {  
            this.image = ret.image;  
            this.imagePath = "file:///" + ret.image;  
        }  

    }  
);  
  • 3、压缩体积教程:

将插件目录中文件lib-lpr-release.aar使用压缩工具打开,根据自己使用的Android平台进行保留jni目录下.so文件,即删除掉多余的平台目录;

目录结构:

├─ package.json  
├─ android  
│  ├── res  
│  │── libs  
│  │── assets  
│  │── uniplugin_lpr-release.aar  
│  └── lib-lpr-release.aar  
└─ ios

lib-lpr-release.aar文件压缩包中目录结构:

├─ AndroidManifest.xml  
├─ classes.jar  
├─ res  
├─ assets  
├─ jni  
│  │── armeabi-v7a  
│  │── arm64-v8a  
│  └── x86  
└─ios

举例:如果当前平台为armeabi-v7a,则只需要保留armeabi-v7a目录即可,其他同级目录arm64-v8ax86均可删除;

完整代码示例

<template>  
    <view class="button-sp-area">  
        <button type="primary" plain="true" @click="showLPR()">点击识别车牌</button>  
        <view style="margin-top: 20px; padding: 20px;" v-show="this.success == true">  
            <view style="text-align: center;color: lightslategray;">  
                <text>车牌号:{{number}}</text>  
            </view>  
            <view style="text-align: center;color: lightslategray;">  
                <text>车牌颜色:{{color}}</text>  
            </view>  
            <view style="text-align: center;color: lightslategray;">  
                <text>图片地址:{{image}}</text>  
            </view>  
            <view style="text-align: center;color: lightslategray;">  
                <image :src="imagePath"></image>  
            </view>  
        </view>  
    </view>  
</template>  

<script>  
    const modal = uni.requireNativePlugin('modal');  
    // 获取 module  
    var plateModule = uni.requireNativePlugin("PlateModule")  
    export default {  
        data() {  
            return {  
                success: false,  
                number: "",  
                color: "",  
                image: "",  
                imagePath: ""  
            }  
        },  
        methods: {  
            showLPR() {  
                console.log('showLPR...')  

                //带参数  
                plateModule.startPlate(  
                    {  
                        'accuracy': 0.80, // 识别准确率(取值范围:0.0-1.0。准确率大于该值才返回结果,值越大识别越准确但也会越慢,需要测试出来最适合自己的准确率)  
                        'quality': 80, // 图像压缩率(取值范围:0-100。 0:压缩100%,100:不压缩)  
                        'showText': true // 是否显示提示文字  
                    },  
                    (ret) => {  
                        console.log("showLPR result : ", ret);  
                        modal.toast({  
                            message: ret,  
                            duration: 1.5  
                        });  
                        //解析  
                        this.success = true;  
                        if (ret.number) {  
                            this.number = ret.number;  
                        }  
                        if (ret.color) {  
                            this.color = ret.color;  
                        }  
                        if (ret.image) {  
                            this.image = ret.image;  
                            this.imagePath = "file:///" + ret.image;  
                        }  

                    }  
                );  
            }  
        }  
    }  
</script>  

<style>  

</style>  
4 关注 分享
BoredApe liend123 3***@qq.com 套马杆的套子

要回复文章请先登录注册

3***@qq.com

3***@qq.com

你好,压缩包在哪里购买
2024-03-06 12:48