uniAPP

UniAPP离线车牌实时扫描识别

2023-01-03  本文已影响0人  一枚假程序猿

插件说明

UniAPP离线车牌实时扫描识别

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

特点:

效果:

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

支持车牌:

序号 车牌类型 是否支持
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 ×

原生插件通用使用流程:

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

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

使用说明

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

使用步骤

// 一行代码引用
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;
        }

    }
);

将插件目录中文件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>

上一篇 下一篇

猜你喜欢

热点阅读