Appearance
使用方法
注意
组件只能在nvue页面中使用,不支持vue页面
组件使用
在需要使用插件的页面加载以下代码
vue
<leven-uts-baiduFace-Person ref="refLevenPerson" style="flex:1; height: 500px;" :config="config" @onError="onError" @onInit="onInit">
</leven-uts-baiduFace-Person>页面示例代码
vue
<template>
<view>
<uni-card title="安卓百度人脸识别UTS原生插件-认证核检">
<view style="flex:1; height: 500px; position: relative;">
<leven-uts-baiduFace-Person ref="refLevenPerson" style="flex:1; height: 500px;" :config="config" @onError="onError" @onInit="onInit">
</leven-uts-baiduFace-Person>
</view>
<view>
<button type="primary" @click="start">开始人证核检</button>
</view>
</uni-card>
<uni-card class="uni-card-box" title="日志">
<view><text style="font-size: 14px; flex-wrap: wrap;">{{logStr}}</text></view>
</uni-card>
</view>
</template>
<script>
export default {
data() {
return {
//日志
logStr: "",
//组件配置
config: {
//默认为80px。可传入大于30px的数值,小于此大小的人脸不予检测
minFaceSize: 50,
//人脸置信度用于表征被检测到的物体是人脸的概率,该阈值设置越高检测越严格,建议在0.3-0.8区间内调整阈值,默认:0.5
faceThreshold: 0.5,
//是否开启属性检测,默认:false
attribute: false,
//是否设置质量检测,默认:true
qualityControl: false,
//质量检测参数设置,qualityControl为true时有效
qualityConfig: {
// 模糊度设置,默认0.8。取值范围[0~1],0是最清晰,1是最模糊
blur: 0.8,
// 光照设置,默认0.8.取值范围[0~1], 数值越大,光线越强
illum: 0.8,
//姿态阈值,默认:15
gesture: 15,
// 左眼被遮挡的阈值,默认0.8
leftEye: 0.8,
// 右眼被遮挡的阈值,默认0.8
rightEye: 0.8,
// 鼻子被遮挡的阈值,默认0.8
nose: 0.8,
// 嘴巴被遮挡的阈值,默认0.8
mouth: 0.8,
// 左脸颊被遮挡的阈值,默认0.8
leftCheek: 0.8,
// 右脸颊被遮挡的阈值,默认0.8
rightCheek: 0.8,
// 下巴被遮挡阈值,默认为0.8
chinContour: 0.8
},
//识别阈值,0-1,默认为0.8
liveScoreThreshold: 0.6,
//摄像头旋转角度,默认:0,可传入0、90、180、270四个选项
videoDirection: 90,
//人脸检测角度,默认:0,可传入0、90、180、270四个选项。
rgbDetectDirection: 90,
//是否开启最优人脸检测,默认:false
usingBestImage: false,
//RGB预览Y轴转向falese为0,true为180
rgbRevert: false,
//摄像头显示位置,-1:usb,0.后置,1.前置,默认:1
rbgCameraId: 1,
//是否开启openGL渲染,默认:false
isOpenGl: false
},
//当前识别的人脸图片
imageBase64: ""
}
},
methods: {
//关闭人脸识别
start() {
if (this.$refs.refLevenPerson) {
this.$refs.refLevenPerson.start({
//核检图片,支持本地和网络地址
// url: "http://www.yeyuboke.com/svga/b.jpg",
url: "/storage/emulated/0/DCIM/Camera/IMG_20240902_141732.jpg",
}, res => {
this.writeLog(JSON.stringify(res))
})
}
},
//错误事件
onError(e) {
this.writeLog(JSON.stringify(e))
},
//初始化事件
onInit(e) {
this.writeLog(JSON.stringify(e))
},
// 写日志
writeLog(str) {
console.log(str)
let logStr = uni.$lv.date.format(null, "yyyy-mm-dd hh:MM:ss") + " " + str + "\n";
// let logStr = str + "\n";
this.logStr = logStr + this.logStr;
}
}
}
</script>
<style>
</style>