首页 > 其他分享 >人脸识别的圆框

人脸识别的圆框

时间:2023-01-07 13:55:24浏览次数:37  
标签:人脸识别 res 50% face width tipsText 圆框 data

<template>
<view class="camera-box">
  <camera class="camera-el" frame-size="large" device-position="front"
  flash="off" @error="error">

  </camera>
  <view class="jc-face-state-hint" v-if="tipsText != ''">
    <view class="mask">
      <view class="text">{{tipsText}}</view>
    </view>
  </view>
  <u-modal :show="showSqModal" confirmColor="#22b3ad" showCancelButton @confirm="openSetting" @cancel="showSqModal = false" content="人脸验证需要您授权摄像头权限, 否则无法使用! 请授权后重新应用或者本页面."></u-modal>
</view>
</template>

 

initCamera() {
  // #ifdef MP-WEIXIN
  wx.initFaceDetect()
  this.context = wx.createCameraContext()
  this.listener = this.context.onCameraFrame((frame) => {
    wx.faceDetect({
    frameBuffer: frame.data,
    width: frame.width,
    height: frame.height,
    enablePoint: true,
    enableConf: true,
    enableAngle: true,
    enableMultiFace: true,
    success: (faceData) => {
      let face = faceData.faceInfo[0]
      if (faceData.x == -1 || faceData.y == -1) {
        this.tipsText = '检测不到人脸'
      }
  if (faceData.faceInfo.length > 1) {
    this.tipsText = '请保证只有一人做认证'
  } else {
    if (face.angleArray.pitch >= 0.3 || face.angleArray.roll >= 0.3 || face.angleArray.yaw >= 0.3) {
    this.tipsText = '请平视摄像头'
  } else if (face.confArray.global <= 0.8 || face.confArray.leftEye <=
    0.8 || face.confArray.mouth <= 0.8 || face.confArray.nose <= 0.8 ||
    face.confArray.rightEye <= 0.8) {
    this.tipsText = '请勿遮挡五官'
  } else {
    // 人脸在,可以执行操作
    this.tipsText = '请保持该状态'
    if(this.captureFace) {
    this.context.takePhoto({
      quality: "normal",
      success: (res) => {
        // tempImagePath 照片文件的临时路径 (本地路径),安卓是 jpg 图片格式,ios是png
        let imgFormat = res.tempImagePath.substring(res.tempImagePath.lastIndexOf(".")+1)
        this.$emit('getFace', res.tempImagePath, imgFormat)
      }
    })
  }

  }
}
},
fail: (err) => {
  // console.log(err)
  if (err.x == -1 || err.y == -1) {
    this.tipsText = '检测不到人脸'
  } else {
    this.tipsText = '网络错误,请退出页面重试'
  }
}
})
})
this.listener.start()
// #endif
}

<style lang="scss" scoped>
.camera-box {
  position: relative;
  width: 75vw;
  height: 75vw;
  background-color: #FFFFFF;
  border-radius: 50%;
  margin: 0 auto 50px auto;
  border: 5px solid #03CAC7;
  .camera-el,
  .jc-face-state-hint {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 97%;
    height: 97%;
    border-radius: 50%;
  }

.jc-face-state-hint {
  z-index: 99;
  overflow: hidden;
  .mask {
    position: relative;
    width: 100%;
    height: 20%;
    background-color: rgba(0,0,0,.3);
    .text {
      position: absolute;
      width: 100%;
      top: 50%;
      transform: translateY(-50%);
      color: #ffffff;
      text-align: center;
    }
  }

  }
}

.goback-btn-box {
width: 50%;
margin: 0 auto;
}
</style>

 以上是子组件中的代码

如组件关键代码如下

getFace(tempImagePath) {
  this.captureFace = false;
  wx.getFileSystemManager().readFile({
    filePath: tempImagePath,
    encoding: "base64",
    success: res => {
      this.$request(this.$operate.apis.searchFaceTencent, {
        // this.$request(this.$operate.apis.searchFace, { //searchFaceTencent //注释的这两个是原来的
        // image_base64: res.data
        external_fields: {
          fileName: this.s_userMsg.name+'-人脸',
          patientId: this.s_userMsg.selfcheckPatientId,
          personName: this.s_userMsg.name
        },
      image_base64: res.data,
      threshold: 0
    }, 'POST').then(res => {

      if (res.data.code == 200 && res.data.data != "") {
        if(res.data.data.selfcheckPatientId == this.s_userMsg.selfcheckPatientId) {
          uni.userC.updateUserMsg('w_userMsg', JSON.parse(res.data.data.wxDetail))
          uni.$u.route({
            type: 'reLaunch',
            url: "/pages/home/home"
          })
        }
      }
      this.captureFace = true;
    }).catch(err => {
      console.log("nono",res)
      this.captureFace = true;
    })

  },
  fail: err => {
    console.log("转换base64失败")
  }
})
}

标签:人脸识别,res,50%,face,width,tipsText,圆框,data
From: https://www.cnblogs.com/yhxy/p/17032544.html

相关文章

  • Java人脸识别相册分类按时间分类相册按城市分类相册app源码
    简介后台Java,前台mui开发的androidapp;主要是按拍摄时间,人脸,城市进行相册照片的分类。演示视频https://www.bilibili.com/video/BV1XP4y187rA/?share_source=copy_web&v......
  • 4步实现树莓派人脸识别、拍照与推送、舵机旋转
        大部分童鞋的树莓派是不是一直在吃灰呢?一直闲置着,倒不如用它做一个简易监控,如果检测到人脸后,就拍照上传到指定地方,或发消息提醒。先看效果吧:准备材料:    能用的......
  • 从图片搜索到人脸识别,CV正在成为“互动营销”领域的【硬核技术】
    写在篇首:营销创意是个「体力活」,考验的是N次改稿中依然振作起来的体力和毅力:从业10年的资深广告人在面对Z世代的脑洞需求时,只能说:套路无效;创意方案从PlanA-PlanZ可以......
  • 反人脸识别的思路和实现
    反人脸识别的思路和实现 一、基本知识和背景    ​人脸识别是非常经典的机器识别运用,目前已经在许多地方得到了使用。相关的算法原理和实现发展的都很发达,Opencv中就......
  • 视频美颜sdk中人脸识别的主要实现流程
    小编在之前文章中多次提到过视频美颜sdk的关键技术之一“人脸识别”,此技术经过漫长的发展周期,直到今天已经迭代了非常多的实现方式,今天小编就为大家讲解一下视频美颜sdk人脸......
  • 带你玩转OpenHarmony AI:基于Seetaface2的人脸识别
     简介随着时代的进步,全民刷脸已经成为一种新型的生活方式,这也是全球科技进步的又一阶梯,人脸识别技术已经成为一种大趋势,无论在智慧出行、智能家居、智慧办公等场景均......
  • 机器学习——人脸识别判断表情
    (一) 选题背景随着机器学习和深度神经网络两个领域的迅速发展以及智能设备的普及,人脸识别技术正在经历前所未有的发展,关于人脸识别技术讨论从未停歇。目前,人脸识别精度已......
  • 一个简单的完整人脸识别系统
    一个简单的完整人脸识别系统from__future__importprint_function#便于测试新版本函数fromtimeimporttime#从time模块导入time,因为有些步骤需要计时importlog......
  • 温州大学《深度学习》课程课件(十、人脸识别与神经风格迁移)
    这学期我上的另一门课是本科生的《深度学习》,主要用的是吴恩达老师的《深度学习》视频课的内容。使用教材:吴恩达《深度学习》课程笔记课外参考书:《深度学习》,人民邮电出版社......
  • 10:Java人脸识别认证-Java API 实战
    (目录)1.提出问题,引入SDK的概念什么是SDK?我们并不具备开发人脸识别的能力,但我们可以用大公司已经开发好的工具或者功能,来实现人脸识别,而大公司提供的就叫SDK(Software......