更新记录
1.0.2(2025-09-25)
- 更新Android依赖包
1.0.1(2025-09-25)
- 增加人脸库管理接口
1.0.0(2025-09-23)
- 人脸识别
查看更多
平台兼容性
uni-app(3.6.5)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| √ |
√ |
- |
- |
√ |
√ |
5.0 |
√ |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(3.6.5)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
5.0 |
√ |
- |
- |
其他
虹软人脸识别离线识别-App人脸识别增值版
开发文档
- 注册登录虹软开发后台
- 创建应用后,右上角点击“添加SDK”按钮,选择“APP人脸识别 增值版”(不要选择到其他版本)
- 集成插件,集成插件步骤请参考
https://www.cnblogs.com/wenrisheng/p/18323027
版本
虹软SDK版本号: Android:V5.0 ios:V3.1
组件
<wrs-uts-arcfaceapp ref="arcfacepro" :style="'width:'+width+'px;height:'+height+'px;'"
@onArcfaceEvent="onArcfaceEvent" :params="params"></wrs-uts-arcfaceapp>
- 使用了改组件的页面要使用nvue或uvue
- params属性参数
- 从相机注册人脸到本地人脸库,注册结果在onArcfaceEvent里回调
let name = getUserName()
let newParams = {}
newParams.businessArray = [{
business: "startRegister",
params: {
name: name
}
}]
let newParamsStr = this.formatNewParams(newParams)
// android、ios
this.params = newParamsStr
// 鸿蒙
this.options = {
params: newParamsStr
}
- 从相机识别识别人脸,识别结果在onArcfaceEvent里回调
// 调用识别接口开始识别
let newParams = {}
newParams.businessArray = [{
business: "startCompare"
}]
let newParamsStr = this.formatNewParams(newParams)
// android、ios
this.params = newParamsStr
// 鸿蒙
this.options = {
params: newParamsStr
}
onArcfaceEvent(e) {
console.log("onArcfaceEvent:" + JSON.stringify(e))
let detail = e.detail
let opt = detail.opt
switch (opt) {
case "onLoadView": {
// 加载试图
}
break;
case "onRegisterFinished":
// 注册结果
let success = detail.success
if (success) {
this.showToast("注册成功!userName:" + this.userName)
// uni.navigateBack()
} else {
this.showToast("注册失败")
}
break;
case "onRecognized":
// 识别对比结果
let compareResult = JSON.parse(detail.compareResult)
let name = compareResult.faceEntity.userName
console.log("识别到用户:" + name)
break;
default:
break;
}
}
接口
import {
UTSArcfaceApp,
UTSFaceMgr
} from "@/uni_modules/wrs-uts-arcfaceapp"
let faceMgr = new UTSFaceMgr()
- 在线激活引擎,激活成功以后下次app启动也不需要激活了
UTSArcfaceApp.activeOnline(this.appId, this.sdkKey, (resp) => {
let flag = resp.flag
if(flag) {
let code = resp.code
// android是0,iOS是200
if (code == 200 || 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查询失败原因");
}
} else {
this.showMsg("没授权")
}
})
let isFront = true
UTSArcfaceApp.setCameraFront(isFront)
let recognizeThreshold = 0.8 // 一般设置为0.8,相似度大于0.8就认为是同一个人
UTSArcfaceApp.setRecognizeThreshold(recognizeThreshold)
人脸库管理
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()