首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在开放式简历中识别头部运动?

如何在开放式简历中识别头部运动?
EN

Stack Overflow用户
提问于 2020-03-04 20:40:55
回答 1查看 486关注 0票数 0

下午好,我目前有一些使用haar级联来检测眼睛和脸部的代码,我很好奇是否有人知道如何让程序识别头部的运动。眼睛的点头或运动,例如眨眼。

这是我目前所拥有的:

代码语言:javascript
运行
复制
   import cv2
import numpy as np
"""
Created on Mon Mar 2 11:38:49 2020

@author: bradl
"""
# Open Camera
camera = cv2.VideoCapture(0)
camera.set(10, 200)

face_cascade = cv2.CascadeClassifier('haarcascades/face.xml')
##smile = cv2.CascadeClassifier('haarcascades/smile.xml')
eye_cascade = cv2.CascadeClassifier('haarcascades/eye.xml')

while True:
    ret, img = camera.read()
    ## converts to gray
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    ## determines what a face is and how it is found
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in faces:
        ## Determines the starting and ending co-ordinates for a blue rectangle to be drawn around the face
        cv2.rectangle (img, (x,y), (x+w, y+h), (255,0,0), 2)
        ## Declares the region of the image where the eyes will be 
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = img[y:y+h, x:x+w]
        ## Determines what an eye is based on the eye haar cascade xml file
        eyes = eye_cascade.detectMultiScale(roi_gray)
        for (ex,ey,ew,eh) in eyes: 
            ##Draws green rectangles around the co-ordintates for eyes 
            cv2.rectangle(roi_color, (ex, ey),(ex+ew,ey+eh), (0,255,0),2)

    ##Displays camera        
    cv2.imshow('Image',img)
    ##Requires the user to press escape to exit the program
    k = cv2.waitKey(40) 
    if k == 27: 
            break

有没有人有办法让程序识别头部或眼睛的运动?

EN

回答 1

Stack Overflow用户

发布于 2020-03-04 20:52:42

有许多方法可以检测眨眼。

在眼睛的感兴趣区域应用白色detection.

  • Draw轮廓的眼睛周围的面具,如果轮廓的面积高于一个阈值,你可以解释眼睛是睁开的,每当有一个突然变化的轮廓区域,这是一个眨眼的点。如果你朝向和远离相机,这种方法将失败。

另一种方法是使用DLIB这样的库进行人脸地标检测。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60526336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档