• uniapp原生插件之安卓虹软人脸识别原生插件


    插件介绍

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

    插件地址

    安卓虹软人脸识别SDK免费版原生插件 - DCloud 插件市场

    超级福利

    uniapp 插件购买超级福利

    详细使用文档

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

    申请权限

    1. android.permission.READ_EXTERNAL_STORAGE
    2. android.permission.READ_PHONE_STATE
    3. android.permission.WRITE_EXTERNAL_STORAGE
    4. android.permission.CAMERA

    API使用

    用法

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

    const module = uni.requireNativePlugin("leven-arcFace-ArcFaceModule");

    页面内容

    1. <template>
    2. <view>
    3. <uni-card title="虹软人脸识别原生插件">
    4. <button type="primary" @click="onlineActive">激活引擎button>
    5. <button type="primary" @click="getImageFace">获取图片人脸信息button>
    6. <button type="primary" @click="imageFaceRegister">图片注册人脸button>
    7. <button type="primary" @click="clearFace">清空人脸库button>
    8. <button type="primary" @click="deleteFace">删除人脸button>
    9. <button type="primary" @click="getFace">获取人脸button>
    10. <button type="primary" @click="getAllFace">获取所有人脸信息button>
    11. <button type="primary" @click="batchRegister">批量注册button>
    12. <button type="primary" @click="getFaceCount">获取注册的人脸数量button>
    13. uni-card>
    14. view>
    15. template>
    16. <script>
    17. const module = uni.requireNativePlugin("leven-arcFace-ArcFaceModule");
    18. export default {
    19. data() {
    20. return {
    21. }
    22. },
    23. methods: {
    24. // 激活引擎
    25. onlineActive() {
    26. module.activeEngine({
    27. appId: "7eHk2fnhwZ4aNHeXBrPceHS8K442TY7d27o1bvfGniod",
    28. sdkKey: "ax9B3CzadBJJ2W8LAHFDWk6JMMQ5bdBtfAwSN5joA4w"
    29. }, res => {
    30. console.log(res)
    31. })
    32. },
    33. // 获取图片人脸信息
    34. getImageFace() {
    35. module.getImageFace({
    36. //本地或网络url地址
    37. url: "/sdcard/DCIM/arcface/1.jpg",
    38. }, res => {
    39. console.log(res)
    40. })
    41. },
    42. // 图片注册人脸信息
    43. imageFaceRegister() {
    44. module.imageFaceRegister({
    45. //本地或网络url地址
    46. url: "/sdcard/DCIM/arcface/2.jpg",
    47. // 保存的id(可以不传该参数,默认时间戳)
    48. id: 123,
    49. //保存的姓名(可以不传该参数,默认时间戳)
    50. name: "leven",
    51. // 同一人是否可以多次注册,默认true
    52. registerMultiple: false
    53. }, res => {
    54. console.log(res)
    55. })
    56. },
    57. // 清空人脸库
    58. clearFace() {
    59. module.clearFace(res => {
    60. console.log(res)
    61. })
    62. },
    63. // 删除人脸
    64. deleteFace() {
    65. module.deleteFace({
    66. id: "123"
    67. }, res => {
    68. console.log(res)
    69. })
    70. },
    71. // 获取人脸
    72. getFace() {
    73. module.getFace({
    74. id: "123"
    75. }, res => {
    76. console.log(res)
    77. })
    78. },
    79. // 批量注册
    80. batchRegister() {
    81. module.batchRegister({
    82. // 同一人是否可以多次注册,默认true
    83. registerMultiple: false,
    84. list: [{
    85. //本地或网络url地址
    86. url: "/sdcard/DCIM/arcface/1.jpg",
    87. // 保存的id(可以不传该参数,默认时间戳)
    88. id: 10001,
    89. //保存的姓名(可以不传该参数,默认时间戳)
    90. name: "leven1"
    91. }, {
    92. //本地或网络url地址
    93. url: "http://www.yeyuboke.com/svga/2.jpg",
    94. // 保存的id(可以不传该参数,默认时间戳)
    95. id: 10002,
    96. //保存的姓名(可以不传该参数,默认时间戳)
    97. name: "leven2"
    98. }, {
    99. //本地或网络url地址
    100. url: "/sdcard/DCIM/arcface/3.jpg",
    101. // 保存的id(可以不传该参数,默认时间戳)
    102. id: 10003,
    103. //保存的姓名(可以不传该参数,默认时间戳)
    104. name: "leven3"
    105. }, {
    106. //本地或网络url地址
    107. url: "http://www.yeyuboke.com/svga/4.jpg",
    108. // 保存的id(可以不传该参数,默认时间戳)
    109. id: 10004,
    110. //保存的姓名(可以不传该参数,默认时间戳)
    111. name: "leven4"
    112. }, {
    113. //本地或网络url地址
    114. url: "/sdcard/DCIM/arcface/5.jpg",
    115. // 保存的id(可以不传该参数,默认时间戳)
    116. id: 10005,
    117. //保存的姓名(可以不传该参数,默认时间戳)
    118. name: "leven5"
    119. }, {
    120. //本地或网络url地址
    121. url: "/sdcard/DCIM/arcface/6.jpg",
    122. // 保存的id(可以不传该参数,默认时间戳)
    123. id: 10006,
    124. //保存的姓名(可以不传该参数,默认时间戳)
    125. name: "leven6"
    126. }]
    127. }, res => {
    128. console.log(res)
    129. })
    130. },
    131. // 获取所有人脸信息
    132. getAllFace() {
    133. module.getAllFace(res => {
    134. console.log(res)
    135. })
    136. },
    137. // 获取注册的人脸数量
    138. getFaceCount() {
    139. module.getFaceCount(res => {
    140. console.log(res)
    141. })
    142. }
    143. }
    144. }
    145. script>
    146. <style>
    147. style>

    人脸识别组件使用

    用法

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

    1. <leven-arcFace ref="refLevenArcFace" style="flex:1; height: 500px;" :camera="camera" :video="video" @onError="onError"
    2. @onCameraOpened="onCameraOpened" @onCameraClosed="onCameraClosed" @onFaceResult="onFaceResult">leven-arcFace>

    页面内容

    1. <template>
    2. <view>
    3. <uni-card title="人脸识别">
    4. <view style="flex:1; height: 500px; position: relative;">
    5. <leven-arcFace ref="refLevenArcFace" style="flex:1; height: 500px;" :camera="camera" :video="video" @onError="onError"
    6. @onCameraOpened="onCameraOpened" @onCameraClosed="onCameraClosed" @onFaceResult="onFaceResult">
    7. leven-arcFace>
    8. <cover-view style="position: absolute; left: 0; top: 0;">
    9. <view><text>这里是自定义文字内容text>view>
    10. cover-view>
    11. view>
    12. <button type="primary" @click="register">注册人脸button>
    13. <button type="primary" @click="switchCamera">切换相机button>
    14. <button type="primary" @click="stop">关闭预览button>
    15. <button type="primary" @click="start">开启预览button>
    16. <button type="primary" @click="closeFace">关闭人脸检测button>
    17. <button type="primary" @click="openFace">开启人脸检测button>
    18. uni-card>
    19. view>
    20. template>
    21. <script>
    22. export default {
    23. data() {
    24. return {
    25. // 摄像机配置,所有的参数都可以不传,不传则按默认的
    26. camera: {
    27. // 相机预览旋转角度
    28. rotation: 0,
    29. //相机预览模式,0:后置,1:前置(默认)
    30. facing: 1,
    31. //预览分辨率
    32. // size: [800, 600],
    33. // 摄像机预览圆角
    34. radius: 50,
    35. // 是否开启预览,默认:true
    36. preview: true
    37. },
    38. // 视频检测配置,所有参数都可以不传,不传则按默认的
    39. video: {
    40. // 视频检测角度,可接收参数,0,90,180,270(默认),360(全方位检测)
    41. orient: 360,
    42. // 是否进行活体检测(默认为true)
    43. liveness: true,
    44. // 人脸注册同一人是否可以多次注册(默认:true)
    45. registerMultiple: false,
    46. // 人脸识别成功后是否展示左上角人脸识别图片(默认:true)
    47. showIdentifyImage: false,
    48. // 人脸框是否处于X反向状态,如果未设置该参数人脸框和人脸处于反向请将该参数设置为true
    49. // isContraryX: true,
    50. // 人脸框是否处于Y反向状态,如果未设置该参数人脸框和人脸处于反向请将该参数设置为true
    51. // isContraryY: true,
    52. // 识别阈值
    53. similar: 0.8,
    54. // 识别的最小人脸比例,如果失败比较敏感可以适当调小,默认:16
    55. detectFaceScaleVal: 10
    56. }
    57. }
    58. },
    59. methods: {
    60. // 注册人脸
    61. register() {
    62. if (this.$refs.refLevenArcFace) {
    63. this.$refs.refLevenArcFace.register({
    64. // 注册后保存的id(可以不传该参数,默认时间戳)
    65. id: "456",
    66. //注册后保存的名字(可以不传该参数,默认时间戳)
    67. name: "leven1"
    68. }, res => {
    69. console.log(res)
    70. });
    71. }
    72. },
    73. // 切换相机
    74. switchCamera() {
    75. if (this.$refs.refLevenArcFace) {
    76. this.$refs.refLevenArcFace.switchCamera(res => {
    77. console.log(res)
    78. });
    79. }
    80. },
    81. // 关闭预览
    82. stop() {
    83. if (this.$refs.refLevenArcFace) {
    84. this.$refs.refLevenArcFace.stop(res => {
    85. console.log(res)
    86. });
    87. }
    88. },
    89. // 开启预览
    90. start() {
    91. if (this.$refs.refLevenArcFace) {
    92. this.$refs.refLevenArcFace.start(res => {
    93. console.log(res)
    94. });
    95. }
    96. },
    97. // 关闭人脸检测
    98. closeFace() {
    99. if (this.$refs.refLevenArcFace) {
    100. this.$refs.refLevenArcFace.closeFace(res => {
    101. console.log(res)
    102. });
    103. }
    104. },
    105. // 开启人脸检测
    106. openFace() {
    107. if (this.$refs.refLevenArcFace) {
    108. this.$refs.refLevenArcFace.openFace(res => {
    109. console.log(res)
    110. });
    111. }
    112. },
    113. // 错误事件
    114. onError(e) {
    115. console.log(e)
    116. },
    117. // 相机打开事件
    118. onCameraOpened(e) {
    119. console.log(e)
    120. },
    121. // 相机关闭事件
    122. onCameraClosed(e) {
    123. console.log(e)
    124. },
    125. // 相机配置改变事件
    126. onCameraConfigurationChanged(e) {
    127. console.log(e)
    128. },
    129. // 人脸识别结果
    130. onFaceResult(e) {
    131. console.log(e)
    132. }
    133. }
    134. }
    135. script>
    136. <style>
    137. style>

    插件方法

    API

    • 激活引擎
    • 获取图片人脸信息
    • 图片注册人脸
    • 清空人脸库
    • 删除人脸
    • 获取人脸
    • 获取所有人脸信息
    • 批量注册
    • 停止批量注册 v1.1.0
    • 获取注册的人脸数量

    组件

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

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

    联系作者

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

    预览图片

     

  • 相关阅读:
    Azkaban环境配置-尚硅谷大数据培训
    高考假期预习指南:开启你的IT学习之旅
    js(javascript)中关于查找与替换常用的实用方法
    11_Shell脚本-简单实例
    LVS-DR模式
    Android 源码 <Activity> 桌面启动二 [6]
    拉线位移编码器要检查机械装置的安装状态
    RabbitMQ 消息中间件与集群的部署
    VS2010配置gdal1.10.0 gdal1.10.1编译
    【Vue全家桶】--- 第六章:vue-router
  • 原文地址:https://blog.csdn.net/lw0911/article/details/134274975