uniapp原生插件之安卓虹软人脸识别增值版原生插件_uniapp 虹软-程序员宅基地

技术标签: 虹软  android  人脸识别  uniapp插件  uni-app  

插件介绍

虹软人脸识别增值版支持在线激活,离线激活,支持图片人脸识别(可识别网络图片),活体检测,离线识别,相机预览旋转,相机人脸识别,批量注册(支持网络图片)等,支持保存用户的id和名称

本插件是增值版插件,如果您想使用免费版插件请点击这里

插件地址

安卓虹软人脸识别增值版原生插件支持在线激活,离线激活,批量注册等 - DCloud 插件市场

详细使用文档

uniapp 安卓虹软人脸识别增值版原生插件使用文档

激活

用法

在需要使用插件的页面加载以下代码

const module = uni.requireNativePlugin("leven-arcFacePro-ActiveModule");

示例 

<template>
  <view>
    <uni-card title="激活">
      <button type="primary" @click="activeOnline">在线激活</button>
      <button type="primary" @click="getDeviceFinger">获取设备指纹信息</button>
      <button type="primary" @click="activeOffline">离线激活</button>
    </uni-card>
  </view>
</template>

<script>
  const module = uni.requireNativePlugin("leven-arcFacePro-ActiveModule");
  export default {
    data() {
      return {

      }
    },
    methods: {
      // 在线激活
      activeOnline() {
        module.activeOnline({
          activeKey: "85Q1-11MH-H13X-QK97",
          appId: "BPeKN1LAULmr364FMisKF3Cds2U3cNaec8PYvxkiSdWm",
          sdkKey: "8Hzo8nFpMj8DWgAaTsQySH2QJoQ1YKUDEAX4w2RL24BU"
        }, res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 获取设备指纹信息
      getDeviceFinger() {
        module.getDeviceFinger(res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 离线激活
      activeOffline() {
        module.activeOffline({
          path: "/storage/emulated/0/Download/WeiXin/85Q111L6B11R1WNE.dat"
        }, res => {
          this.showToast(JSON.stringify(res))
        })
      },
      showToast(content) {
        console.log(content)
        // uni.showToast({
        //   icon: "none",
        //   title: content
        // })
      }
    }
  }
</script>

<style>

</style>

人脸管理

用法

在需要使用插件的页面添加以下代码

const module = uni.requireNativePlugin("leven-arcFacePro-FaceManagerModule");

示例

<template>
  <view>
    <uni-card title="人脸管理">
      <button type="primary" @click="init">初始化</button>
      <button type="primary" @click="getImageFace">获取图片人脸信息</button>
      <button type="primary" @click="imageFaceRegister">图片注册人脸</button>
      <button type="primary" @click="clearFace">清空人脸库</button>
      <button type="primary" @click="deleteFace">删除人脸</button>
      <button type="primary" @click="getFace">获取人脸</button>
      <button type="primary" @click="getAllFace">获取所有人脸信息</button>
      <button type="primary" @click="batchRegister">批量注册</button>
      <button type="primary" @click="getFaceCount">获取注册的人脸数量</button>
    </uni-card>

    <!-- 注册进度弹窗 -->
    <process ref="refProcess" :processTitle="batchRegisterProcess.processTitle" :process="batchRegisterProcess.process"
      :successCount="batchRegisterProcess.successCount" :failedCount="batchRegisterProcess.failedCount" :totalCount="batchRegisterProcess.totalCount">
    </process>
  </view>
</template>

<script>
  // 批量注册人脸的文件
  import {
    faceList
  } from "@/utils/face.js"
  //加载组件
  import process from "./process.nvue"
  const module = uni.requireNativePlugin("leven-arcFacePro-FaceManagerModule");
  export default {
    components: {
      process
    },
    data() {
      return {
        //批量注册进度
        batchRegisterProcess: {
          //进度描述
          processTitle: "0",
          //当前进度
          process: 0,
          // 成功数量
          successCount: 0,
          //失败数量
          failedCount: 0,
          //注册总数量
          totalCount: 0
        }
      }
    },
    methods: {
      // 初始化
      init() {
        module.init(res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 获取图片人脸信息
      getImageFace() {
        module.getImageFace({
          //本地或网络url地址
          url: "/sdcard/DCIM/Camera/IMG_20230225_175710.jpg",
        }, res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 图片注册人脸
      imageFaceRegister() {
        module.imageFaceRegister({
          //本地或网络url地址
          // url: "/storage/emulated/0/Pictures/WeiXin/mmexport1701242375957.jpg",
          url: "http://www.yeyuboke.com/svga/4.jpg",
          // 保存的id(可以不传该参数,默认时间戳)
          id: 123,
          //保存的姓名(可以不传该参数,默认时间戳)
          name: "leven",
          // 同一人是否可以多次注册,默认true
          registerMultiple: false
        }, res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 清空人脸库
      clearFace() {
        module.clearFace(res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 删除人脸
      deleteFace() {
        module.deleteFace({
          id: "123"
        }, res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 获取人脸
      getFace() {
        module.getFace({
          id: "123"
        }, res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 批量注册
      batchRegister() {
        if (this.$refs.refProcess) {
          this.$refs.refProcess.open();
        }
        let list = [];
        faceList.map(item => {
          let obj = {
            id: item._id,
            name: item.name,
            url: item.pic
          }
          list.push(obj)
        })
        this.batchRegisterProcess.totalCount = list.length;
        module.batchRegister({
          // 同一人是否可以多次注册,默认true
          registerMultiple: false,
          list: list
        }, res => {
          // console.log(res);
          if (res.code == 0) {
            let data = res.data || {};
            let status = data.status;
            if (status == "registerFinish") {
              //注册完成
              if (this.$refs.refProcess) {
                this.$refs.refProcess.close();
              }
              uni.$lv.func.toast("注册结束");
            } else if (status == "registering") {
              //注册中
              let successCount = data.successCount || 0;
              let failedCount = data.failedCount || 0;
              let progress = data.progress || 0;
              let progressValue = progress.toFixed(4);
              //高精度乘法
              progressValue = uni.$lv.number.mul(progressValue, 100);
              this.batchRegisterProcess.failedCount = failedCount;
              this.batchRegisterProcess.process = Math.floor(progressValue);
              this.batchRegisterProcess.processTitle = progressValue + "";
              this.batchRegisterProcess.successCount = successCount;
            }
          }
        })
      },
      // 获取所有人脸信息
      getAllFace() {
        module.getAllFace(res => {
          this.showToast(JSON.stringify(res))
        })
      },
      // 获取注册的人脸数量
      getFaceCount() {
        module.getFaceCount(res => {
          this.showToast(JSON.stringify(res))
        })
      },
      showToast(content) {
        uni.showToast({
          icon: "none",
          title: content
        })
      }
    }
  }
</script>

<style>

</style>

 人脸识别

用法

在需要使用插件的页面添加以下代码

<leven-arcFacePro ref="refLevenArcFacePro" style="flex:1; height: 500px;" :camera="camera" :video="video" @onError="onError"
      @onCameraOpened="onCameraOpened" @onCameraClosed="onCameraClosed" @onFaceResult="onFaceResult">
    </leven-arcFacePro>

示例

    <template>
  <view>
    <uni-card title="人脸识别">
      <view style="flex:1; height: 500px; position: relative;">
        <leven-arcFacePro ref="refLevenArcFacePro" style="flex:1; height: 500px;" :camera="camera" :video="video" @onError="onError"
          @onCameraOpened="onCameraOpened" @onCameraClosed="onCameraClosed" @onFaceResult="onFaceResult">
        </leven-arcFacePro>
        <!-- 组件内部自定义内容 -->
        <!-- <cover-view style="position: absolute; right: 0; bottom: 0;">
          <view><text>这里是自定义文字内容</text></view>
        </cover-view> -->
      </view>
      <view>
        <button type="primary" @click="register">注册人脸</button>
        <button type="primary" @click="switchCamera">切换相机</button>
        <button type="primary" @click="stop">关闭预览</button>
        <button type="primary" @click="start">开启预览</button>
        <button type="primary" @click="closeFace">关闭人脸检测</button>
        <button type="primary" @click="openFace">开启人脸检测</button>
        <button type="primary" @click="setCamera">更新摄像机属性</button>
        <button type="primary" @click="setVideo">更新视频检测属性</button>
        <button type="primary" @click="reInit">重载组件</button>
      </view>
    </uni-card>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        //相机属性,所有的参数都可以不传,不传则按默认的
        camera: {
          // 相机预览旋转角度
          rotation: 0,
          //相机模式,1.前置,0.后置(默认)
          facing: 1,
          // 摄像机预览圆角,默认:0
          radius: 50,
          //预览分辨率,默认:[1280,720]
          size: [1280, 720],
        },
        // 视频检测配置,所有参数都可以不传,不传则按默认的
        video: {
          // 视频检测角度,可接收参数,0,90,180,270,360(默认)
          orient: 360,
          // 人脸框是否处于X反向状态,如果未设置该参数人脸框和人脸处于反向请将该参数设置为true
          isContraryX: false,
          // 人脸框是否处于Y反向状态,如果未设置该参数人脸框和人脸处于反向请将该参数设置为true
          isContraryY: false,
          // 识别阈值(默认:0.8)
          similar: 0.9,
          // 是否进行活体检测(默认为true)
          liveness: true,
          //识别是否展示面部信息(默认为true)
          showFaceInfo: false
        }
      }
    },
    methods: {
      // 注册人脸
      register() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.register({
            // 注册后保存的id(可以不传该参数,默认时间戳)
            id: "123",
            //注册后保存的名字(可以不传该参数,默认时间戳)
            name: "leven",
            //同一人脸是否可以多次注册
            registerMultiple: false,
          }, res => {
            console.log(res)
          });
        }
      },
      // 切换相机
      switchCamera() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.switchCamera(res => {
            console.log(res)
          });
        }
      },
      // 关闭预览
      stop() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.stop(res => {
            console.log(res)
          });
        }
      },
      // 开启预览
      start() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.start(res => {
            console.log(res)
          });
        }
      },
      // 关闭人脸检测
      closeFace() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.closeFace(res => {
            console.log(res)
          });
        }
      },
      // 开启人脸检测
      openFace() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.openFace(res => {
            console.log(res)
          });
        }
      },
      // 设置摄像机属性,设置完属性后需调用一次重载组件方可生效
      setCamera() {
        if (this.$refs.refLevenArcFacePro) {
          let params = JSON.parse(JSON.stringify(this.camera));
          params.rotation = 90;
          params.facing = 1;
          params.radius = 10;
          params.size = [800, 600];
          this.$refs.refLevenArcFacePro.setCamera(params, res => {
            console.log(res)
          });
        }
      },
      // 设置视频检测属性,设置完属性后需调用一次重载组件方可生效
      setVideo() {
        if (this.$refs.refLevenArcFacePro) {
          let params = JSON.parse(JSON.stringify(this.video));
          params.orient = 360;
          params.liveness = false;
          params.isContraryX = true;
          params.isContraryY = true;
          params.similar = 0.95;
          params.showFaceInfo = true;
          this.$refs.refLevenArcFacePro.setVideo(params, res => {
            console.log(res)
          });
        }
      },
      // 重载组件
      reInit() {
        if (this.$refs.refLevenArcFacePro) {
          this.$refs.refLevenArcFacePro.reInit(res => {
            console.log(res)
          });
        }
      },
      // 错误事件
      onError(e) {
        console.log(e)
      },
      // 相机打开事件
      onCameraOpened(e) {
        console.log(e)
      },
      // 相机关闭事件
      onCameraClosed(e) {
        console.log(e)
      },
      // 相机配置改变事件
      onCameraConfigurationChanged(e) {
        console.log(e)
      },
      // 人脸识别结果
      onFaceResult(e) {
        console.log(e)
      }
    }
  }
</script>

<style>

</style>

插件方法

激活

  • 在线激活
  • 获取设备指纹信息
  • 离线激活

人脸管理

  • 初始化
  • 获取图片人脸信息
  • 图片注册人脸
  • 清空人脸库
  • 删除人脸
  • 获取人脸
  • 获取所有人脸信息
  • 批量注册
  • 获取注册的人脸数量

组件

  • 组件方法
    • 相机注册人脸
    • 切换相机
    • 关闭预览
    • 开启预览
    • 关闭人脸检测
    • 开启人脸检测
    • 设置摄像机属性
    • 设置视频检测属性
  • 组件属性
    • 摄像机配置
    • 视频检测配置
  • 组件事件
    • 错误事件
    • 相机打开事件
    • 相机关闭事件
    • 相机配置改变事件
    • 人脸识别结果

具体方法的使用请参考使用说明文档

联系作者

购买插件前请先试用,试用通过再购买。在试用中如果遇到任何问题,可与作者联系,QQ:334106817,将全力协助你使用本插件

预览图片

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lw0911/article/details/134980957

智能推荐

Docker安装:Errors during downloading metadata for repository ‘appstream‘:_"cenerrors during download metadata for repository-程序员宅基地

文章浏览阅读1k次。centos8问题参考CentOS 8 EOL如何切换源? - 云服务器 ECS - 阿里云_"cenerrors during download metadata for repository \"appstream"

尚硅谷_谷粒学苑-微服务+全栈在线教育实战项目之旅_基于微服务的在线教育平台尚硅谷-程序员宅基地

文章浏览阅读2.7k次,点赞3次,收藏11次。SpringBoot+Maven+MabatisPlusmaven在新建springboot项目引入RELEASE版本出错maven在新建springboot项目引入RELEASE版本出错maven详解maven就是通过pom.xml中的配置,就能够从仓库获取到想要的jar包。仓库分为:本地仓库、第三方仓库(私服)、中央仓库springframework.boot:spring-boot-starter-parent:2.2.1.RELEASE’ not found若出现jar包下载不了只有两_基于微服务的在线教育平台尚硅谷

java 实现 数据库备份_java数据备份-程序员宅基地

文章浏览阅读1k次。数据库备份的方法第一种:使用mysqldump结合exec函数进行数据库备份操作。第二种:使用php+mysql+header函数进行数据库备份和下载操作。下面 java 实现数据库备份的方法就是第一种首先我们得知道一些mysqldump的数据库备份语句备份一个数据库格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 ..._java数据备份

window10_ffmpeg调试环境搭建-编译64位_win10如何使用mingw64编译ffmpeg-程序员宅基地

文章浏览阅读3.4k次,点赞2次,收藏14次。window10_ffmpeg调试环境搭建_win10如何使用mingw64编译ffmpeg

《考试脑科学》_考试脑科学pdf百度网盘下载-程序员宅基地

文章浏览阅读6.3k次,点赞9次,收藏14次。给大家推荐《考试脑科学》这本书。作者介绍:池谷裕二,日本东京大学药学系研究科教授,脑科学研究者。1970年生于日本静冈县,1998年取得日本东京大学药学博士学位,2002年起担任美国哥伦比亚大学客座研究员。专业为神经科学与药理学,研究领域为人脑海马体与大脑皮质层的可塑性。现为东京大学药学研究所教授,同时担任日本脑信息通信融合研究中心研究主任,日本药理学会学术评议员、ERATO人脑与AI融合项目负责人。2008年获得日本文部大臣表彰青年科学家奖,2013年获得日本学士院学术奖励奖。这本书作者用非常通俗易懂_考试脑科学pdf百度网盘下载

今天给大家介绍一下华为智选手机与华为手机的区别_华为智选手机和华为手机的区别-程序员宅基地

文章浏览阅读1.4k次。其中,成都鼎桥通信技术有限公司是一家专业从事移动通讯终端产品研发和生产的高科技企业,其发布的TD Tech M40也是华为智选手机系列中的重要代表之一。华为智选手机是由华为品牌方与其他公司合作推出的手机产品,虽然其机身上没有“华为”标识,但是其品质和技术水平都是由华为来保证的。总之,华为智选手机是由华为品牌方和其他公司合作推出的手机产品,虽然外观上没有“华为”标识,但其品质和技术水平都是由华为来保证的。华为智选手机采用了多种处理器品牌,以满足不同用户的需求,同时也可以享受到华为全国联保的服务。_华为智选手机和华为手机的区别

随便推点

Linux常用命令_ls-lmore-程序员宅基地

文章浏览阅读4.8k次,点赞17次,收藏51次。Linux的命令有几百个,对程序员来说,常用的并不多,考虑各位是初学者,先学习本章节前15个命令就可以了,其它的命令以后用到的时候再学习。1、开机 物理机服务器,按下电源开关,就像windows开机一样。 在VMware中点击“开启此虚拟机”。2、登录 启动完成后,输入用户名和密码,一般情况下,不要用root用户..._ls-lmore

MySQL基础命令_mysql -u user-程序员宅基地

文章浏览阅读4.1k次。1.登录MYSQL系统命令打开DOS命令框shengfen,以管理员的身份运行命令1:mysql -u usernae -p password命令2:mysql -u username -p password -h 需要连接的mysql主机名(localhost本地主机名)或是mysql的ip地址(默认为:127.0.0.1)-P 端口号(默认:3306端口)使用其中任意一个就OK,输入命令后DOS命令框得到mysql>就说明已经进入了mysql系统2. 查看mysql当中的._mysql -u user

LVS+Keepalived使用总结_this is the redundant configuration for lvs + keep-程序员宅基地

文章浏览阅读484次。一、lvs简介和推荐阅读的资料二、lvs和keepalived的安装三、LVS VS/DR模式搭建四、LVS VS/TUN模式搭建五、LVS VS/NAT模式搭建六、keepalived多种real server健康检测实例七、lvs持久性工作原理和配置八、lvs数据监控九、lvs+keepalived故障排除一、LVS简介和推荐阅读的资料 学习LVS+Keepalived必须阅读的三个文档。1、 《Keepalived权威指南》下载见http://..._this is the redundant configuration for lvs + keepalived server itself

Android面试官,面试时总喜欢挖基础坑,整理了26道面试题牢固你基础!(3)-程序员宅基地

文章浏览阅读795次,点赞20次,收藏15次。AIDL是使用bind机制来工作。java原生参数Stringparcelablelist & map 元素 需要支持AIDL其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。下图是我进阶学习所积累的历年腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。

机器学习-数学基础02补充_李孟_新浪博客-程序员宅基地

文章浏览阅读248次。承接:数据基础02

短沟道效应 & 窄宽度效应 short channel effects & narrow width effects-程序员宅基地

文章浏览阅读2.8w次,点赞14次,收藏88次。文章目录1. 概念:Narrow Width Effect: 窄宽度效应Short Channel effects:短沟道效应阈值电压 (Threshold voltage)2. 阈值电压与沟道长和沟道宽的关系:Narrow channel 窄沟的分析Short channel 短沟的分析1. 概念:Narrow Width Effect: 窄宽度效应在CMOS器件工艺中,器件的阈值电压Vth 随着沟道宽度的变窄而增大,即窄宽度效应;目前,由于浅沟道隔离工艺的应用,器件的阈值电压 Vth 随着沟道宽度_短沟道效应