更新记录

1.0.0(2019-11-19)

暂无


平台兼容性

import OCR from '@/common/js/js_sdk/BaiDu-OCR/BaiDu-OCR.js';

//识别身份证
var res=await OCR.ocr({func:'idcard',b64:imgData,side:'front'/*'back'*/})
//识别银行卡
var res=await OCR.ocr({func:'bankcard',image:imgData})
//活体检测
var result=await OCR.ocr({func:'detect',max_face_num:1,face_field:'quality',b64:imgData})
//人脸检测
var result=await OCR.ocr({func:'faceverify',images:images})
//人脸比对
var result=await OCR.ocr({func:'match',Live_Image:this.faceToken,IDCard_Image:b64})

注意:

client_id=APIKey&client_secret=secretKey 这两个参数请你在申请百度云人脸识别应用后填入你自己的值 若是全局引用,可在main.js中

import OCR from '@/common/js/js_sdk/BaiDu-OCR/BaiDu-OCR.js';

Vue.prototype.OCR = OCR

vue文件中引用: await this.OCR.ocr({...此处填入具体参数})

//此处列出图片转base64的转换函数,使用中遇到了很多坑。
//本地图片路径转换base64
    p2B64(path) {
        console.log('path:',path)
        return new Promise(function(resolve, reject) {
        //#ifdef MP-WEIXIN
            uni.getFileSystemManager().readFile({
                filePath: path,
                encoding: 'base64',
                success: function(res) {
                    resolve(res.data)
                },
                fail: function(error) {
                    reject(error)
                }
            })
        // #endif
        //#ifdef APP-PLUS
            // 此方法不能加载过大的图片文件,否则报图片加载失败,所以注释掉换用plus.io的方法实现
            // var bitmap = new plus.nativeObj.Bitmap("bitmap"); //bitmap标识谁便取
            // // 从本地加载Bitmap图片 
            // bitmap.load(path,()=>{ 
            //  var base64=bitmap.toBase64Data(); 
            //  bitmap.recycle();
            //  // console.log('base64:',base64)
            //  var datastr=base64.split(',')[1];
            //  resolve(datastr);
            // },(e)=>{ 
            //  console.log('加载图片失败:',e); 
            //  bitmap.recycle();
            //  resolve({status:0,msg:e})
            // })
            plus.io.resolveLocalFileSystemURL(path, function(entry){
                entry.file(function(file){  
                    var reader = new plus.io.FileReader();  
                    reader.onloadend = function (e) {
                        var base64=e.target.result
                        console.log(base64);
                        resolve(base64.split(',')[1]);
                    };  
                    reader.readAsDataURL(file);  
                },function(e){  
                    console.log("读写出现异常: " + e.message );
                    reject(e);
                })  
            }) 
        //#endif
        //#ifdef H5
            //Html5 Web API 专用接口
            //var path = document.getElementById("file").files[0]; 
            var imgFile = new FileReader();
            console.log('path:',path)
            imgFile.readAsDataURL(path);
            imgFile.onload = function () {
                var imgData = this.result; //base64数据  
                console.log(imgData);
                resolve(imgData);
            }
            // <p>  
            //     <label>请选择一个文件:</label>  
            //     <input type="file" id="file" />  
            // </p>  

        //#endif
            return
        })

隐私、权限声明

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

暂无

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

暂无

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

暂无

许可协议

MIT协议

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