更新记录

1.0.1(2025-09-02)

  1. 增加人脸库管理
  2. 增加参数设置

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 - - -

其他

多语言 暗黑模式 宽屏模式

虹软人脸识别离线识别-人脸识别增值版

开发文档

  1. 注册登录虹软开发后台
  2. 创建应用后,点击“添加SDK”按钮,选择“人脸识别 增值版”(不要选择到其他版本),选择5.0版本,然后选择Android平台,java语言等,获取试用码
  3. 集成插件,集成插件步骤请参考 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()

隐私、权限声明

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

<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

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

插件不采集任何数

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