更新记录
2.0.16(2025-06-28)
1.新增手机号识别
2.新增电动车车牌识别
2.0.15(2025-06-14)
1.客户问题修复 2.新增行驶证识别
2.0.14(2025-06-11)
- 新增三个参数:
| scanColor | String | empty | 扫描线颜色,默认空,为没有扫描线,需要扫描线请设置颜色,完整8位格式:
- AA:透明度(Alpha,00=全透明,FF=不透明)
- RR:红色(Red)
- GG:绿色(Green)
- BB:蓝色(Blue) 例如:#8041C7E2 这个是半透明的淡蓝se | | customerToken | String | empty | 客户定制界面token,专门给定制客户的,只有定制时才涉及 | | bgColor | String | #64000000 | 扫描页面颜色,默#64000000,为半透明,需要时请设置颜色,完整8位格式:
- AA:透明度(Alpha,00=全透明,FF=不透明)
- RR:红色(Red)
- GG:绿色(Green)
- BB:蓝色(Blue) 例如:#8041C7E2 这个是半透明的淡蓝se | 2 .客户定制车牌扫描界面
平台兼容性
uni-app(4.43)
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 4.4 | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
uni-app x(4.43)
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 5.0 | - | - | - |
示例使用
点击右边“使用HBuilderX导入示例项目”,导入后示例中有个PDF文件,按照文件运行项目。
效果视频(可在抖音或者直接复制链接浏览器打开看)
1.身份证 https://v.douyin.com/iU2y8Q1w/
2 银行卡 https://v.douyin.com/iU2yGhv3/
3 车牌号 https://v.douyin.com/iU2UVwES/
一切都是本地处理,不需要任何的服务器,数据安全可靠,没有任何泄露
实际测试已对 华为,三星,荣耀,小米,OPPO,VIVO,REALME,REDMI,IQOO兼容(包含手机和平板),部分非主流手机兼容,如果还有部分不兼容的可联系作者进行兼容,争取做到全兼容!!!
汽车行业已定制的界面,需要使用请联系作者。图片预览如果有问题,请点击链接查看
平台兼容性
目前支持Android,CPU类型支持arm64-v8a,armeabi-v7a android目前适配到API 34
插件功能
- OCR识别文本功能(主要是中文,英文也可以)
- 支持相册和相机选择图片
- 文本返回内容可配置
- 身份证识别
- 车牌识别
- 银行卡识别
- 营业执照识别 为加快识别速度,请配置skipMatchParams,例子:"businessArea#businessAddress#validDate#socialCreditCode#registerMoney"
- 自定义证件识别
- 社保卡识别
- 发票识别
- 车架号识别
- 行驶证 为加快识别速度,请配置skipMatchParams,例子:"owner#engineNo#bandType#address#issueDate#registerDate#vehicleType"
- 手机号识别
- 电动自行车车牌
在线使用插件通用流程
- 购买此插件,选择该插件绑定的项目(使用者项目)。
- 购买页面导入到相应项目。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包。
APK 体验(问题日志上报):
+通过网盘分享的文件:app-release.apk +链接: https://pan.baidu.com/s/1Mkbuqnil22N3eaXxJDsoyg?pwd=uk46 提取码: uk46
插件API的使用
引入插件
import {OCROptions,uTSOCRRecognize,LScanOptions,getBase64FromFilePath} from "@/uni_modules/xt-ocr-recognize"
使用插件(完整Demo使用代码,请适配到自己项目)
Demo源码可以在以下网盘下载
-通过百度网盘分享的文件:SampleAp… -链接:https://pan.baidu.com/s/1i5JBhXXHf5E_PCvQVZ1Tdg?pwd=5bre -提取码:5bre -复制这段内容打开「百度网盘APP 即可获取」
uniapp版本
<template>
<view class="content">
<img class="imgi" :src="basesrc" alt="Base64 JPG Image"></img>
<button @tap="take">拍照</button>
<div class="text-wrapper">{{title}}</div>
</view>
</template>
<script>
import {OCROptions,uTSOCRRecognize,getBase64FromFilePath} from "@/uni_modules/xt-ocr-recognize"
export default {
data() {
return {
title: 'scan result placehodle',
fptah : "",
basesrc: "/static/logo.png",
}
},
onLoad() {
},
methods: {
take() {
const that = this;
uTSOCRRecognize({
params: '{"recognizeType": 3,"showBeep": true,"imgLocation": 0,"pickTextFromImg": false,"pickTextAreaType": 3,"textAreaType": 1}',
complete: (res) => {
console.log(res);
that.title = res;
var resu = JSON.parse(res);
console.log(resu.result);
if (resu.result) {
console.log(resu.result.imagePath);
that.fptah = resu.result.imagePath;
that.getimg();
}
}
});
},
getimg() {
const that = this;
getBase64FromFilePath({
params: that.fptah,
complete: (res) => {
console.log("base64 callback");
that.basesrc = "data:image/jpeg;base64," + res;
},
});
},
},
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.imgi{
max-width: 100%; /* 响应式图片 */
height: auto; /* 保持图片比例 */
border-radius: 5px; /* 添加圆角 */
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.text-wrapper {
height: 500rpx;
width: 500rpx;
word-break: break-all;
word-wrap: break-word
}
</style>
uniapp x 版本
<template>
<view>
<image class="imgi" :src="basesrc" alt="Base64 JPG Image"></image>
<view class="text-area">
<button @click="take">拍照</button>
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
import {OCROptions,LScanOptions,uTSOCRRecognize,getBase64FromFilePath} from "@/uni_modules/xt-ocr-recognize"
export default {
data() {
return {
title: 'scan result placehodle',
basesrc: "/static/logo.png",
fptah : "",
}
},
onLoad() {
},
methods: {
take() {
const that = this;
let options = {
params: `{
'recognizeType':1,
'imgLocation': 0,
'pickTextFromImg': true,
'pickTextAreaType': 0,
'textAreaType':1,
}`,
complete: (res : any) => {
console.log(res);
let strR:string = res.toString();
that.title = strR;
let jsonData:UTSJSONObject = JSON.parse(strR) as UTSJSONObject;
if (jsonData["result"] != null) {
let result:UTSJSONObject = jsonData["result"] as UTSJSONObject;
that.fptah = result["imagePath"] as string;
that.getimg();
}
}
} as OCROptions;
uTSOCRRecognize(options);
},
getimg() {
console.log("getimg");
const that = this;
let options = {
params: that.fptah,
complete: (res : any) => {
console.log("base64 callback");
that.basesrc = "data:image/jpeg;base64," + res;
}
} as LScanOptions;
getBase64FromFilePath(options);
},
}
}
</script>
<style>
.logo {
height: 100px;
width: 100px;
margin: 100px auto 25px auto;
}
.title {
font-size: 18px;
color: #8f8f94;
text-align: center;
}
</style>
参数说明
uTSOCRRecognize
接口参数
参数名 | 参数类型 | 参数默认值 | 参数说明 |
---|---|---|---|
recognizeType | Integer | 0 | 如果不是普通文本识别,imgLocation和pickTextFromImg不生效,为默认值,自动返回相应的识别内容,内容格式后面有说明 0 - 普通文本识别 1- 身份证识别正面,返回值JSON格式(身份证号码,姓名,性别,民族,出生,地址, 照片地址) 2 - 身份证识别反面,返回值JSON格式(签发机关,有效期限,照片地址) 3 - 车牌扫描 4 - 银行卡扫描 5-营业执照 6 自定义证件 7 社保卡识别 8 发票 9 车架号 10 行驶证 11手机号 12电动车自行车车牌 |
imgLocation | Integer | 0 | recognizeType = 0 时使用,识别图片选取方式 0 - camera 相机获取 1 - album 相册获取 |
pickTextFromImg | Boolean | False | recognizeType = 0 时使用,识别文本是否手动从图片中选择,这个取值受textAreaType和pickTextAreaType影响 True - 返回值手动从已识别的图片上获取,返回值类型为文本,选择区域受pickTextAreaType影响 False - 直接返回结果,返回值是JSON对象,返回值内容受textAreaType影响 |
textAreaType | Integer | 0 | recognizeType = 0 时使用,当pickTextFromImg 为False时,设置该值,文本返回区域类型 0 - block 1 - line 2 - element 3 - symbol 具体数据类型会有说明 |
pickTextAreaType | Integer | 0 | recognizeType = 0 时使用,当pickTextFromImg 为True时,设置该值,文本选取区域类型 0 - block 1 - line 2 - element 3 - symbol |
forceVertical | Boolean | false | recognizeType <= 4 使用,强制竖屏,默认是横屏,横屏识别率高 |
scanHintText | String | 参考文档后面的截图,每种证件都有默认值,支持中英文 | 识别界面文案设置,一般不用设置,除非自己有需求 |
showPhotoAlbum | Boolean | False | recognizeType > 0 使用,证件识别界面是否支持相册选取,相册选取识别失败率高(慎重选择) |
showLightController | Boolean | True | 证件识别界面是否支持打开手电筒 |
showVibrate | Boolean | True | 识别成功后是否震动提示 |
isSupportZoom | Boolean | False | 扫描界面是否支持放大拉近 |
showBeep | Boolean | False | 识别成功后是否beep音提示 |
customizeTags | String | empty | recognizeType为6时生效,自定义扫描证件需要扫描的内容类型,参考后面截图的例子,最多设置15个,为一个String类型的JSONArray数组,这些类型在选择内容是会展示,参考文档最后的使用说明图片 |
customizeKeyWords | String | empty | recognizeType为6时生效,自定义扫描证件需要扫描的关键词,识别时匹配到关键词才认为扫描成功。最少设置3个, ###为每个关键词间的分隔符,如:统一社会信用代码###营业执照###注册资本###法定代表人, 参考文档最后的使用说明图 |
skipMatchParams | String | empty | 为了加速某些复杂证件的识别,目前用于营业执照和行驶证,跳过某些参数的匹配,让某些参数不作为必须匹配项,加速识别速度。每个跳过参数直接用#分隔。对于营业执照,示例:businessArea#businessAddress#validDate#socialCreditCode#registerMoney。这些参数可以看返回结果JSON中的key |
multiVerify | boolean | False | 为了提升车牌号和车架号的识别正确率,以识别速度换取正确率,可以配置这个为true |
scanColor | String | empty | 扫描线颜色,默认空,为没有扫描线,需要扫描线请设置颜色,完整8位格式: - AA:透明度(Alpha,00=全透明,FF=不透明) - RR:红色(Red) - GG:绿色(Green) - BB:蓝色(Blue) 例如:#8041C7E2 这个是半透明的淡蓝se |
customerToken | String | empty | 客户定制界面token,专门给定制客户的,只有定制时才涉及 |
bgColor | String | #64000000 | 扫描页面颜色,默#64000000,为半透明,需要时请设置颜色,完整8位格式: - AA:透明度(Alpha,00=全透明,FF=不透明) - RR:红色(Red) - GG:绿色(Green) - BB:蓝色(Blue) 例如:#8041C7E2 这个是半透明的淡蓝se |
customizeTags示例:
[
{
"typeName": "公司名称",
"typeTag": "copName"
},
{
"typeName": "业务覆盖范围",
"typeTag": "region"
},
{
"typeName": "业务类型",
"typeTag": "bType"
},
{
"typeName": "住所(营业场所)",
"typeTag": "address"
}
]
customizeKeyWords示例:
中华人民共和国###支付业务许可证###公司名称
返回结果
回调结果是一个JSON格式数据,包含两个属性
返回值名称 | 返回值类型 | 返回值说明 |
---|---|---|
status | String | 成功为"success",其他为失败 |
result | String | 只有成功时才有,内容为识别结果,不同扫描类型结果不一样,最后面会有详细说明 |
getBase64FromFilePath
接口参数
只需要传入文件路径,文件路径来着识别结果。
返回结果
返回结果是图片的Base64的编码数据
识别样例(具体返回结果)
普通文本
自动返回
以下是textAreaType 为block 为例,其他类型类似
{
"status": "success",
"result": {
"text": "ocr all txt",
"blocks": [
{
"blockText": "block text",
"blockCornerPoints": [
{
"x": 358,
"y": 160
},
{
"x": 724,
"y": 160
},
{
"x": 724,
"y": 204
},
{
"x": 358,
"y": 204
}
],
"blockBoundingBox": {
"left": 358,
"top": 160,
"right": 724,
"bottom": 204
}
}
]
}
}
手动选择
{
"status": "success",
"result":{
"1": "11月8日晚,北京人民大会堂。新华社记者",
"2": "的镜头记录下这样一个瞬间一******"
}
}
身份证正反面
{
"result": {
"birthday": "19xx年x月x日",
"address": "xx市xx区xx镇xxx村卫村xx号",
"nation": "汉",
"imagePath": "file:///storage/emulated/0/Android/data/xxxxxxx/files/Pictures/JPEG_20241110_201015_***50226338.jpg",
"headIcon": "file:///storage/emulated/0/Android/data/xxxxxxx/files/Pictures/JPEG_20241110_201015_sdasdsdas226338.jpg",
"sex": "女",
"name": "xxx",
"idNo": "xxxxxxxxxxxxxxxxxx"
},
"status": "success"
}
{
"result": {
"imagePath": "file:///storage/emulated/0/Android/data/xxxxxxx/files/Pictures/JPEG_20241110_201256_***72854502.jpg",
"validPeriod": "20xx.11.05-20xx.11.05",
"issueOrg": "xx市***xx分局"
},
"status": "success"
}
车牌号
1 - 新能源小型车
2 - 新能源大型车
3 - 正常燃油车
4 - 特种车牌(学、挂、领、试、超、练、警)
5 - 武警车牌
6 - 港澳牌
7 - 民航牌
{
"result": {
"licensePlate": "粤BXXXXX",
"imagePath": "file:///storage/emulated/0/Android/data/xxxxx/files/Pictures/JPEG_20241110_200433_***38471308.jpg",
"licensePlateTypeName": "正常燃油车",
"licensePlateType": 3
},
"status": "success"
}
银行卡
{
"result": {
"bankInfo": "北京银行·京卡",
"validDate": "12/33",
"imagePath": "file:///storage/emulated/0/Android/data/xxx/files/Pictures/JPEG_20241110_202533_2807726231230176340.jpg",
"cardId": "621468xxxxxxxxxxx"
},
"status": "success"
}
营业执照
证件图片来自:营业执照 支持的类型:
https://gimg2.baidu.com/image_search/src=https%3A%2F%2Fwww.generalwatertech.com%2Fuploadfiles%2F2020%2F01%2F20200109175314541.jpg%3FMS5qcGc%3D&refer=http%3A%2F%2Fwww.generalwatertech.com&app=2002&size=f10000,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1750729101&t=d162e836d2e1a544e74f76bb63916bb7
https://img0.baidu.com/it/u=980771503,1131783134&fm=253&app=120&f=JPEG?w=500&h=667
https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnews.cnr.cn%2Fdj%2F20200227%2FW020200227754444270459.png&refer=http%3A%2F%2Fnews.cnr.cn&app=2002&size=f10000,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1750736300&t=bba9425e8bc231f0722d165d59697d78
https://img0.baidu.com/it/u=1046212889,443452567&fm=253&app=120&f=JPEG?w=500&h=749
https://5b0988e595225.cdn.sohucs.com/images/20190518/720cd4e7c9e546ecbef51300777375f6.jpeg
https://img1.baidu.com/it/u=263093160,2733748875&fm=253&fmt=auto&app=138&f=JPEG?w=714&h=500
{
"result": {
"businessArea": "水处理设备、环保产品及零部件,空气调节设备及其零部件、家用电器、燃气器具、电热水器具、太阳能设备、医疗器械的研究、批发、进出口、佣金代理(拍卖除外)并提供相关配套服务。【依法须经批准的项目,经相关部门批准后方可开展经营活动",
"validDate": "2019年08月28日至2049年08月27日",
"imagePath": "file:///storage/emulated/0/Android/data/com.baidu.paddle.fastdeploy.app.examples/files/Pictures/JPEG_20241116_152406_676366076038016934.jpg",
"businessName": "极易净水科技(上海)有限公司",
"businessLicenseNumber": "01000002201908280013",
"registerMoney": "美元150.0000万",
"businessType": "有限责任公司(台港澳法人独资)",
"businessAddress": "上海市黄浦区新码头街55号4幢3楼",
"socialCreditCode": "91310000MA1FPFRF44",
"createDate": "2019年08月28日",
"legalPeople": "朱芮"
},
"status": "success"
}
自定义证件
传参:
customizeTags示例:
[
{
"typeName": "公司名称",
"typeTag": "copName"
},
{
"typeName": "业务覆盖范围",
"typeTag": "region"
},
{
"typeName": "业务类型",
"typeTag": "bType"
},
{
"typeName": "住所(营业场所)",
"typeTag": "address"
}
]
customizeKeyWords示例:
中华人民共和国###支付业务许可证###公司名称
返回值:
{
"bType": "业务类型:预付卡发行与受理",
"address": "住所(营业场所):郑州高新区冬青街7号",
"imagePath": "file:///storage/emulated/0/Android/data/xxx/files/Pictures/JPEG_20241124_121007_62***332520.jpg",
"region": "业务霞盖范国:河南省",
"copName": "公司名称:河南汇银丰信息技术有限公司"
}
社保卡识别
{
"result": {
"bankCardNo": "622202xxxxxxxxxxx",
"socialSecurityNumber": "3xxxxxxxxxxxxxx",
"imagePath": "file:///storage/emulated/0/Android/data/com.xxxxxx/files/Pictures/JPEG_20250412_142037_689682***22.jpg",
"name": "xxxx",
"bankCardType": "工商银行·E时代卡",
"cardNo": "1xxxxxxxxxxxxxxxxxx"
},
"status": "success"
}
车架号识别
{
"result": {
"imagePath": "file:///data/user/0/uni.app.UNI4A0AA55/files/imgs/BMP_20250605_195921_8807504625742551773.bmp",
"vin": "LFVBA14B3Y3014078"
},
"status": "success"
}
行驶证识别
{
"result": {
"owner": "xxx",
"engineNo": "K06xxx0",
"bandType": "丰田牌TVxxxGL",
"licensePlate": "苏Axxxx3",
"address": "江苏省xxxxxxxx86号",
"imagePath": "file:///data/user/0/com.baxxxloy.app.examples/files/imgs/BMP_20250614_150210_***16700005.bmp",
"vin": "LFMAYxxxxxxx4",
"issueDate": "2017-03-03",
"vehicleType": "xxxxx",
"registerDate": "2017-03-03"
},
"status": "success"
}
手机号识别
{
"result": {
"imagePath": "file:///data/user/0/com.baidu.paddle.fastdeploy.app.examples/files/imgs/BMP_20250628_134109_3972537105523688394.bmp",
"phoneNumbers": [
"***",
"***",
"***",
"***"
]
},
"status": "success"
}
电动/自行车牌
{
"result": {
"bicyclePlate": "苏A0xxxxx",
"imagePath": "file:///data/user/0/com.baidu.paddle.fastdeploy.app.examples/files/imgs/BMP_20250628_140144_754773632239087848.bmp"
},
"status": "success"
}