资源简介
压缩包中含有【人眼识别+眨眼识别】源代码以及详细使用教程,利用pyrhon+opencv在ubuntu上运行,实现实时的检测,windows环境的配置需要自己在网上找相关教程,注意,压缩包中缺少的imutils库需另外从我的资源中下载,谢谢大家
代码片段和文件信息
# Command line parameters
# python Wink.py --shape-predictor shape_predictor_68_face_landmarks.dat --video your videoname.mp4
# python Wink.py --shape-predictor shape_predictor_68_face_landmarks.dat
# import the necessary packages
from scipy.spatial import distance as dist
from imutils.video import FileVideoStream
from imutils.video import VideoStream
from imutils import face_utils
import numpy as np
import argparse
import imutils
import time
import dlib
import cv2
def eye_aspect_ratio(eye):
# compute the euclidean distances between the two sets of
# vertical eye landmarks (x y)-coordinates
A = dist.euclidean(eye[1] eye[5])
B = dist.euclidean(eye[2] eye[4])
# compute the euclidean distance between the horizontal
# eye landmark (x y)-coordinates
C = dist.euclidean(eye[0] eye[3])
# compute the eye aspect ratio
ear = (A + B) / (2.0 * C)
# return the eye aspect ratio
return ear
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument(“-p“ “--shape-predictor“ required=True
help=“path to facial landmark predictor“)
ap.add_argument(“-v“ “--video“ type=str default=““
help=“path to input video file“)
args = vars(ap.parse_args())
# define two constants one for the eye aspect ratio to indicate
# blink and then a second constant for the number of consecutive
# frames the eye must be below the threshold
EYE_AR_THRESH = 0.25
EYE_AR_CONSEC_frameS = 2
# initialize the frame counters and the total number of blinks
COUNTER = 0
TOTAL = 0
# initialize dlib‘s face detector (HOG-based) and then create
# the facial landmark predictor
print(“[INFO] loading facial landmark predictor...“)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(args[“shape_predictor“])
# grab the indexes of the facial landmarks for the left and
# right eye respectively
(lStart lEnd) = face_utils.FACIAL_LANDMARKS_IDXS[“left_eye“]
(rStart rEnd) = face_utils.FACIAL_LANDMARKS_IDXS[“right_eye“]
# start the video stream thread
print(“[INFO] starting video stream thread...“)
#vs = FileVideoStream(args[“video“]).start()
fileStream = True
vs = VideoStream(src=0).start()
fileStream = False
time.sleep(1.0)
# loop over frames from the video stream
while True:
# if this is a file video stream then we need to check if
# there any more frames left in the buffer to process
if fileStream and not vs.more():
break
# grab the frame from the threaded video file stream resize
# it and convert it to grayscale
# channels)
frame = vs.read()
frame = imutils.resize(frame width=450)
gray = cv2.cvtColor(frame cv2.COLOR_BGR2GRAY)
# detect faces in the grayscale frame
rects = detector(gray 0)
# loop over the face detections
for rect in rects:
# determine the facial landmarks for the face region then
# convert the facial landmark (x y)-coordinates to a NumPy
# array
shape = predictor(gray
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 99693937 2017-03-03 03:40 shape_predictor_68_face_landmarks.dat
文件 4862 2017-11-12 10:14 Wink.py
文件 118229 2017-11-12 10:46 教程.docx
----------- --------- ---------- ----- ----
99817028 3
- 上一篇:Python从入门到项目实践全彩版
- 下一篇:python项目开发案例集锦.zip
相关资源
- python实现SGBM图像匹配算法
- python实现灰度直方图均衡化
- scrapy_qunar_one
- Python学习全系列教程永久可用
- python简明教程.chm
- 抽奖大转盘python的图形化界面
- 双边滤波器实验报告及代码python
- python +MYSQL+HTML实现21蛋糕网上商城
- Python-直播答题助手自动检测出题搜索
- OpenCV入门教程+OpenCV官方教程中文版
- Python 串口工具源码+.exe文件
- Python开发的全栈股票系统.zip
- Python操作Excel表格并将其中部分数据写
- python书籍 PDF
- 利用python绘制散点图
- python+labview+No1.vi
- 老男孩python项目实战
- python源码制作whl文件.rar
- python3.5可用的scipy
- PYTHON3 经典50案例.pptx
- 计算机科学导论-python.pdf
- python模拟鼠标点击屏幕
- windows鼠标自动点击py脚本
- 鱼c小甲鱼零基础学python全套课后题和
- Python 练习题100道
- Practical Programming 2nd Edition
- wxPython Application Development Cookbook
- python 3.6
- Python 3.5.2 中文文档 互联网唯一CHM版本
- python3.5.2.chm官方文档
评论
共有 条评论