人脸识别活体检测之张张嘴和眨眨眼——Landmark

 /**  
* @Title: Landmark.java
* @Package org.entity
* @Description: TODO该方法的主要作用:
* @author A18ccms A18ccms_gmail_com  
* @date 2018-6-8 上午10:39:01
* @blog https://blog.csdn.net/qq_34137397
* @version V1.0  
*/
package org.entity;

import java.util.ArrayList;
import java.util.List;

 /**   
 *    
 * 项目名称:test_face_huoti   
 * 类名称:Landmark   
 * 类描述:   关键点的实体类
 * 创建人:Mu Xiongxiong  
 * 创建时间:2018-6-8 上午10:39:01   
 * 修改人:Mu Xiongxiong   
 * 修改时间:2018-6-8 上午10:39:01   
 * 修改备注:   
 * 个人博客:https://blog.csdn.net/qq_34137397
 * @version    
 *    
 */
public class Landmark {

    private List<Double> left_eye_zhongxin = new ArrayList<Double>();   //左眼中心
    private List<Double> left_eye_top = new ArrayList<Double>();        //左眼上边
    private List<Double> right_eye_top = new ArrayList<Double>();       //右眼上边
    private List<Double> left_eye_bottom = new ArrayList<Double>();     //左眼下边
    private List<Double> right_eye_bottom = new ArrayList<Double>();    //右眼下边
    private List<Double> right_eye_zhongxin = new ArrayList<Double>();  //右眼中心
    private List<Double> nose_zhongxin = new ArrayList<Double>();       //鼻尖
    private List<Double> mouse_zhongxin = new ArrayList<Double>();      //嘴巴中心
    private List<Double> mouse__top = new ArrayList<Double>();          //嘴巴上边
    private List<Double> mouse__bottom = new ArrayList<Double>();       //嘴巴下边

    public List<Double> getLeft_eye_zhongxin() {
        return left_eye_zhongxin;
    }

    public void setLeft_eye_zhongxin(List<Double> left_eye_zhongxin) {
        this.left_eye_zhongxin = left_eye_zhongxin;
    }

    public List<Double> getRight_eye_zhongxin() {
        return right_eye_zhongxin;
    }

    public void setRight_eye_zhongxin(List<Double> right_eye_zhongxin) {
        this.right_eye_zhongxin = right_eye_zhongxin;
    }

    public List<Double> getNose_zhongxin() {
        return nose_zhongxin;
    }

    public void setNose_zhongxin(List<Double> nose_zhongxin) {
        this.nose_zhongxin = nose_zhongxin;
    }

    public List<Double> getMouse_zhongxin() {
        return mouse_zhongxin;
    }

    public void setMouse_zhongxin(List<Double> mouse_zhongxin) {
        this.mouse_zhongxin = mouse_zhongxin;
    }

    public List<Double> getLeft_eye_top() {
        return left_eye_top;
    }

    public void setLeft_eye_top(List<Double> left_eye_top) {
        this.left_eye_top = left_eye_top;
    }

    public List<Double> getRight_eye_top() {
        return right_eye_top;
    }

    public void setRight_eye_top(List<Double> right_eye_top) {
        this.right_eye_top = right_eye_top;
    }

    public List<Double> getLeft_eye_bottom() {
        return left_eye_bottom;
    }

    public void setLeft_eye_bottom(List<Double> left_eye_bottom) {
        this.left_eye_bottom = left_eye_bottom;
    }

    public List<Double> getRight_eye_bottom() {
        return right_eye_bottom;
    }

    public void setRight_eye_bottom(List<Double> right_eye_bottom) {
        this.right_eye_bottom = right_eye_bottom;
    }

    public List<Double> getMouse__top() {
        return mouse__top;
    }

    public void setMouse__top(List<Double> mouse__top) {
        this.mouse__top = mouse__top;
    }

    public List<Double> getMouse__bottom() {
        return mouse__bottom;
    }

    public void setMouse__bottom(List<Double> mouse__bottom) {
        this.mouse__bottom = mouse__bottom;
    }



}
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要实现调用摄像头进行人脸识别,可以使用WebRTC技术,它是一种支持浏览器之间实时通信的开放标准。在这个过程中,需要使用到一些JavaScript库,如Face-api.js和TensorFlow.js等。 在使用Face-api.js进行人脸识别时,可以通过检测关键点的位置来判断眼、张嘴摇头等动作。比如,检测眼时可以根据眼睛关键点的位置变化来计算眼睛的开合程度,当眼睛开合程度超过一定阈值时就可以判断为眼。 以下是一个简单的示例代码,用于检测眼动作: ```javascript const video = document.getElementById("video"); Promise.all([ faceapi.nets.tinyFaceDetector.loadFromUri("/models"), faceapi.nets.faceLandmark68Net.loadFromUri("/models"), faceapi.nets.faceRecognitionNet.loadFromUri("/models"), faceapi.nets.faceExpressionNet.loadFromUri("/models") ]).then(startVideo); function startVideo() { navigator.getUserMedia( { video: {} }, stream => video.srcObject = stream, err => console.error(err) ) } video.addEventListener('play', () => { const canvas = faceapi.createCanvasFromMedia(video); document.body.append(canvas); const displaySize = { width: video.width, height: video.height }; faceapi.matchDimensions(canvas, displaySize); setInterval(async () => { const detections = await faceapi.detectAllFaces(video, new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceExpressions(); const resizedDetections = faceapi.resizeResults(detections, displaySize); canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height); faceapi.draw.drawDetections(canvas, resizedDetections); faceapi.draw.drawFaceLandmarks(canvas, resizedDetections); const leftEye = resizedDetections[0].landmarks.getLeftEye(); const rightEye = resizedDetections[0].landmarks.getRightEye(); const eyeAspectRatio = (faceapi.euclideanDistance(leftEye[1], leftEye[5]) + faceapi.euclideanDistance(leftEye[2], leftEye[4])) / (2 * faceapi.euclideanDistance(leftEye[0], leftEye[3])); if (eyeAspectRatio < 0.2) { console.log("Blink detected!"); } }, 100); }); ``` 在上述代码中,我们使用了Face-api.js库来进行人脸识别。首先,我们加载了必要的模型文件,然后通过调用`startVideo`函数来启动摄像头。在视频播放时,我们使用`detectAllFaces`函数来检测视频中出现的所有人脸,并计算出每个人脸的关键点。然后,我们根据左右眼的关键点位置计算出眼睛的开合程度,当开合程度小于一定阈值时,就可以判断为眼动作。 类似地,检测张嘴摇头动作也可以使用类似的方法,通过计算关键点位置的变化来判断。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

穆雄雄

哎,貌似还没开张来着呢~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值