更新记录
1.0.1(2026-04-15)
- 界面UI优化
1.0.0(2026-04-15)
- 初版
平台兼容性
uni-app(5.06)
| Vue2 | Vue2插件版本 | Vue3 | Vue3插件版本 | Chrome | Safari | app-vue | app-nvue | Android | Android插件版本 | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| √ | 1.0.0 | √ | 1.0.0 | - | - | - | - | 5.0 | 1.0.0 | - | - |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - | - | - | - |
uni-app x(5.06)
| Chrome | Safari | Android | Android插件版本 | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|---|
| - | - | 5.0 | 1.0.0 | - | - | - |
xwq-ocr-recognize
基于 UTS 车牌识别插件,当前重点支持 Android。
功能说明
- 实时相机车牌识别
- 从系统相册选择图片识别车牌
- 传入应用本地图片绝对路径识别车牌
- 成功回调返回车牌信息、置信度、车牌类型和缓存图片地址
- 自动处理图片 EXIF 方向,提升横拍、竖拍图片识别成功率
导出方法
import {
showLPRScanner,
recognizeImage,
recognizeImagePath
} from "@/uni_modules/xwq-ocr-recognize";
showLPRScanner(options)
打开实时车牌扫描页。
recognizeImage(options)
打开系统相册选择图片并识别车牌。
recognizeImagePath(imagePath, options)
传入应用本地图片绝对路径,直接识别车牌。
imagePath: 应用可访问的本地绝对路径,支持file://前缀或普通绝对路径
回调字段说明
成功回调结构:
type CallbackValType = {
type: string,
option: {
plate?: string,
imagePath?: string | null,
plateType?: number | null,
plateTypeName?: string | null,
confidence?: number | null
}
}
字段说明:
plate: 识别到的车牌号imagePath: 插件复制到应用外部缓存目录后的图片地址,页面可直接用于<image>、<img>等组件展示plateType: 车牌类型数值plateTypeName: 车牌类型中文名称confidence: 识别置信度
imagePath 典型返回示例:
/storage/emulated/0/Android/data/uni.app.xxxxx/cache/xwq-ocr-recognize/local_123456789.jpg
Vue 页面调用示例
<template>
<view class="page">
<button @click="scanPlate">实时识别</button>
<button @click="pickPlate">相册识别</button>
<button @click="recognizeLocalPlate">本地路径识别</button>
<view class="result">
<text>车牌号:{{ result.plate }}</text>
<text>车牌类型:{{ result.plateTypeName }}</text>
<text>置信度:{{ result.confidenceText }}</text>
<text selectable="true">图片地址:{{ result.imagePath }}</text>
<image
v-if="result.imagePath"
:src="result.imagePath"
mode="widthFix"
class="preview"
/>
</view>
</view>
</template>
<script>
import {
showLPRScanner,
recognizeImage,
recognizeImagePath
} from "@/uni_modules/xwq-ocr-recognize";
export default {
data() {
return {
result: {
plate: "",
plateTypeName: "-",
confidenceText: "-",
imagePath: ""
}
};
},
methods: {
updateResult(res) {
const option = res && res.option ? res.option : {};
this.result = {
plate: option.plate || "",
plateTypeName: option.plateTypeName || "-",
confidenceText: typeof option.confidence === "number"
? (option.confidence * 100).toFixed(2) + "%"
: "-",
imagePath: option.imagePath || ""
};
},
scanPlate() {
showLPRScanner({
success: (res) => {
this.updateResult(res);
},
error: (err) => {
console.log("实时识别失败", err);
}
});
},
pickPlate() {
recognizeImage({
success: (res) => {
this.updateResult(res);
},
error: (err) => {
console.log("相册识别失败", err);
}
});
},
recognizeLocalPlate() {
const localImagePath = "/storage/emulated/0/Android/data/uni.app.xxxxx/files/test.jpg";
recognizeImagePath(localImagePath, {
success: (res) => {
this.updateResult(res);
},
error: (err) => {
console.log("本地图片识别失败", err);
}
});
}
}
};
</script>
<style>
.page {
padding: 16px;
}
.result {
margin-top: 16px;
display: flex;
flex-direction: column;
gap: 8px;
}
.preview {
width: 100%;
margin-top: 12px;
}
</style>
说明
- 插件会将识别图片回调,方便页面直接访问
- 实时相机识别、相册识别、本地路径识别三种方式都会返回
imagePath - 相册图片和本地路径图片都会尝试按 EXIF 方向自动纠正后再识别
- Android 5.0 及以上可用

收藏人数:
购买源码授权版(
试用
赞赏(0)
下载 1077
赞赏 6
下载 11554905
赞赏 1905
赞赏
京公网安备:11010802035340号