更新记录

1.0.9(2024-04-07)

1.0.9(2024-04-03)

1、更好识别模型,提升识别准确率 2、修复ios云打包报错

1.0.8(2023-09-25)

1、调整安卓端文字识别数据返回格式 2、修复部分bug

1.0.7(2023-09-11)

超强升级 1、新增支持ios端 2、新增支持返回正面或背面的识别数据 3、更好新的识别模型,提升识别准确率 4、缩减插件包大小,插件包大小不超过10M

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:5.0 - 14.0 armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 适用版本区间:11 - 17

原生插件通用使用流程:

  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原生插件配置”->”云端插件“列表中删除该插件重新选择


插件使用说明:

引入方式

const ocrModule = uni.requireNativePlugin("YY-TomatoOCR")

调用方法

ocrModule.ocrAsyncFunc(options,callback)

参数说明:

传入格式 参数 类型 参数说明
options json 传入参数
callback function 返回结果

options:

普通文字识别: 参数 类型 参数说明
filePath String 图片绝对路径
base64 String 图片base64字符串

filePath和base64只需要传一个,返回数据格式为数组

身份证识别: 参数 类型 必填 参数说明
type String 类型:idcard
sourceType array album 从相册选图,camera 使用相机,默认二者都有
side String front 正面,back 背面,默认:自动返回正面或背面数据
showCorp boolean 是否返回切图,默认:false

返回数据格式为参考下面使用方法

使用方法:

<template>
    <div>
        <button type="primary" @click="takePhoto">拍照OCR识别</button>
        <button type="primary" @click="idcard">身份证识别</button>
    </div>
 </template>

引入插件

<script>
    const ocrModule = uni.requireNativePlugin("YY-TomatoOCR")
    const modal = uni.requireNativePlugin('modal');
        export default {
            onLoad() {},
            methods: {
                takePhoto() {
                    uni.chooseImage({
                        count: 6, //默认9
                        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
                        sourceType: ['camera'], //从相册选择
                        success: function(res) {
                            console.log(JSON.stringify(res.tempFilePaths));

                            uni.getImageInfo({
                                src: res.tempFilePaths[0],
                                success: function(image) {
                                    // 调用异步方法
                                    ocrModule.ocrAsyncFunc({
                                            'filePath': image.path
                                        },
                                        (ret) => {
                                            console.log(JSON.stringify(ret));
                                            modal.toast({
                                                message: JSON.stringify(ret),
                                                duration: 5
                                            });
                                        })
                                }
                            });
                        }
                    });
                },
                idcard() {
                    ocrModule.ocrAsyncFunc({
                            'type': 'idcard',
                            "sourceType": ['camera','album'],
                            "showCorp": true
                        },
                        (ret) => {
                            if (ret){
                                console.log(JSON.stringify(ret.result));
                                modal.toast({
                                    message: JSON.stringify(ret.result),
                                    duration: 5
                                });
                                this.src1 = ret.filePath;
                                this.src2 = ret.base64;
                            }
                        })
                }
            }
        }
    </script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

"android.permission.CAMERA","android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE" "NSPhotoLibraryUsageDescription","NSCameraUsageDescription"

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问