更新记录
1.0.1(2025-09-02)
- 增加人脸库管理
- 增加参数设置
1.0.0(2025-09-01)
活体人脸识别
平台兼容性
云端兼容性
uni-app(4.07)
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
√ |
√ |
- |
- |
√ |
√ |
5.0 |
- |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(4.07)
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
5.0 |
- |
- |
- |
其他
虹软人脸识别离线识别-人脸识别增值版
开发文档
- 注册登录虹软开发后台
- 创建应用后,点击“添加SDK”按钮,选择“人脸识别 增值版”(不要选择到其他版本),选择5.0版本,然后选择Android平台,java语言等,获取试用码
- 集成插件,集成插件步骤请参考
https://www.cnblogs.com/wenrisheng/p/18323027
版本
虹软SDK版本号: Android:V5.0
组件
<wrs-uts-arcfacepro ref="arcfacepro" :style="'width:'+width+'px;height:'+height+'px;'" @onLoadView="onLoadView"
@onArcfaceEvent="onArcfaceEvent"></wrs-uts-arcfacepro>
- 使用了改组件的页面要使用nvue或uvue
- 从相机录入人脸到本地人脸裤
let userName = "张三"
this.$refs["arcfacepro"].startRegister(userName)
this.$refs["arcfacepro"].startCompare()
- onLoadView,视图加载事件
- onArcfaceEvent,人脸注册/识别事件
onArcfaceEvent(e) {
console.log(JSON.stringify(e))
let dynamicJSONFields = e.detail.dynamicJSONFields
let opt = dynamicJSONFields.opt
switch (opt) {
case "onRegisterFinished":
let success = dynamicJSONFields.success
if (success) {
this.showToast("注册成功!userName:" + this.userName)
// uni.navigateBack()
} else {
this.showToast("注册失败")
}
break;
case "onRegisterMaskProblem":
this.showToast("注册不要带口罩")
break;
case "onRecognized":
let faceEntity = dynamicJSONFields.compareResult.dynamicJSONFields.faceEntity.dynamicJSONFields
let userName = faceEntity.userName
this.showToast("识别成功:" + userName)
break;
default:
break;
}
}
接口
import {
UTSArcFace,
UTSFaceMgr
} from "@/uni_modules/wrs-uts-arcfacepro"
let faceMgr = new UTSFaceMgr()
UTSArcFace.isActive((resp) => {
let code = resp.code
if (code == 0 || code == 90114) {
this.showMsg("引擎已经激活")
}
})
UTSArcFace.activeOnline(this.activeKey, this.appId, this.sdkKey, (resp) => {
let code = resp.code
if (code == 0) {
this.showMsg("引擎激活成功")
} else if (code == 90114) {
this.showMsg("引擎已经激活")
} else if (code == 98309) { // 该激活码已被其他设备使用
this.showMsg("该激活码已被其他设备使用");
} else { // 激活失败
// 在https://ai.arcsoft.com.cn/ucenter/resource/build/index.html#/help查询激活失败原因
var msg = resp.msg;
this.showMsg("激活失败, code:" + code +
" 在https://ai.arcsoft.com.cn/ucenter/resource/build/index.html#/help查询失败原因");
}
})
let path = "/xxx/xxx/active_result.dat" // 本地文件绝对路径
UTSArcFace.activeOffline(path, (resp) => {
let code = resp.code
if (code == 0) {
this.showMsg("引擎激活成功")
} else if (code == 90114) {
this.showMsg("引擎已经激活")
} else if (code == 98309) { // 该激活码已被其他设备使用
this.showMsg("该激活码已被其他设备使用");
} else { // 激活失败
// 在https://ai.arcsoft.com.cn/ucenter/resource/build/index.html#/help查询激活失败原因
var msg = resp.msg;
this.showMsg("激活失败, code:" + code +
" 在https://ai.arcsoft.com.cn/ucenter/resource/build/index.html#/help查询失败原因");
}
})
UTSArcFace.getActiveDeviceInfo((resp) => {
let finger = resp.finger
this.showMsg("指纹:" + finger)
})
let isFront = true
UTSArcFace.setCameraFront(isFront)
- 设置识别角度,一些外接到摄像头需要配置识别角度才能识别到人脸
let array = ["0", "90", "180", "270", "all"]
this.showActionSheet(array, (index) => {
UTSArcFace.setFtOrient(array[index])
})
let recognizeThreshold = 0.8 // 一般设置为0.8,相似度大于0.8就认为是同一个人
UTSArcFace.setRecognizeThreshold(recognizeThreshold)
// 是否支持双目摄像机
let canOpenDualCamera = UTSArcFace.canOpenDualCamera()
let array = []
if (canOpenDualCamera) {
array = ["rgb_liveness", "ir_liveness", "disable_liveness"]
} else {
array = ["rgb_liveness", "disable_liveness"]
}
this.showActionSheet(array, (index) => {
UTSArcFace.setLivenessDetectType(array[index])
})
let obj = UTSArcFace.getCommonSupportedPreviewSize()
let array = obj.data
this.showActionSheet(array, (index) => {
UTSArcFace.setPreviewSize(array[index])
})
人脸库管理
let pageSize = 20
faceMgr.initData(pageSize)
let reload = false // true表示获取第一页的数据,false表示获取下一页的数据
faceMgr.getFaceData(reload, (resp) => {
let data = resp.data
if (data) {
this.dataArray.push(...data)
}
})
let userName = "" + new Date().getTime() // 用户名
let path = "/afa/ss/aa.jpg" // 源图片路径,支持绝对路径,如:/afa/ss/aa.jpg或远程网络路径,如:https://ssss/ss.jpg
faceMgr.registerFace(path, userName, (resp) => {
let success = resp.success
if (success) {
this.showMsg("注册成功!userName:" + userName)
this.refreshFaceData()
} else {
this.showMsg("注册失败")
}
});
let localImagePath = UTSArcFace.getResourcePath("/static/test.jpg")
let remoteImagePath = "http://192.168.2.248:8080/file/test.jpg"
let userName = "" + new Date().getTime()
let params = {}
params.data = [{
url: localImagePath,
userName: userName + "1"
}, {
url: remoteImagePath,
userName: userName + "2"
}]
faceMgr.registerMoreFace(params, (resp)=>{
let opt = resp.opt
switch (opt) {
case "onFinish":
this.refreshFaceData()
break;
default:
break;
}
this.showMsg(JSON.stringify(resp))
})
// 通过faceId删除
let faceId = 11
faceMgr.deleteFaceByFaceId(faceId, ()=>{
this.refreshFaceData()
})
// 通过用户名删除
let userName = "张三"
faceMgr.deleteFaceByUserName(userName, ()=>{
this.refreshFaceData()
})
faceMgr.clearAllFaces((resp) => {
})
let totalCount = faceMgr.getFaceTotalFaceCount()