资源简介
压缩包中含有【人眼识别+眨眼识别】源代码以及详细使用教程,利用pyrhon+opencv在ubuntu系统上运行,实现实时的检测。
代码片段和文件信息
# 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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 2343 2017-05-01 03:41 新建文件夹\imutils-master\.gitignore
文件 2858 2017-05-01 03:41 新建文件夹\imutils-master\bin\range-detector
....... 896 2017-05-01 03:41 新建文件夹\imutils-master\demos\encode_image.py
....... 531 2017-05-01 03:41 新建文件夹\imutils-master\demos\feature_demo.py
....... 466 2017-05-01 03:41 新建文件夹\imutils-master\demos\finding_function_names.py
....... 2426 2017-05-01 03:41 新建文件夹\imutils-master\demos\fps_demo.py
....... 2621 2017-05-01 03:41 新建文件夹\imutils-master\demos\image_basics.py
....... 351 2017-05-01 03:41 新建文件夹\imutils-master\demos\image_paths.py
....... 490 2017-05-01 03:41 新建文件夹\imutils-master\demos\opencv_versions.py
....... 908 2017-05-01 03:41 新建文件夹\imutils-master\demos\perspective_transform.py
....... 2980 2017-05-01 03:41 新建文件夹\imutils-master\demos\picamera_fps_demo.py
....... 1567 2017-05-01 03:41 新建文件夹\imutils-master\demos\sorting_contours.py
....... 758 2017-05-01 03:41 新建文件夹\imutils-master\demos\temp_file.py
....... 40682 2017-05-01 03:41 新建文件夹\imutils-master\demo_images\bridge.jpg
....... 29151 2017-05-01 03:41 新建文件夹\imutils-master\demo_images\cactus.jpg
....... 304438 2017-05-01 03:41 新建文件夹\imutils-master\demo_images\notecard.png
....... 12956 2017-05-01 03:41 新建文件夹\imutils-master\demo_images\pyimagesearch_logo.jpg
....... 9041 2017-05-01 03:41 新建文件夹\imutils-master\demo_images\shapes.png
....... 33723 2017-05-01 03:41 新建文件夹\imutils-master\demo_images\workspace.jpg
....... 552360 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\auto_canny.png
....... 922504 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\matplotlib.png
....... 1818052 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\perspective_transform.png
....... 549234 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\resizing.png
....... 1221658 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\rotation.png
....... 323931 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\skeletonization.png
....... 471807 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\sorting_contours.png
....... 659289 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\translation.png
....... 641 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\translation_eq.png
....... 497647 2017-05-01 03:41 新建文件夹\imutils-master\docs\images\url_to_image.png
....... 1504 2017-05-01 03:41 新建文件夹\imutils-master\imutils\contours.py
............此处省略46个文件信息
相关资源
- python+opencv-tessert OCR 实现简易的车牌
- Python人脸相似度对比
- python基础教程pdf第四版中文最新版.
- python项目黑马程序员/传智
- python教学视频
- 面向Arcgis的python脚本编程_数据
- Visual Studio 2015 CUDA 8.0 Python 3.5: Caffe
- 《Python标准库》.(Doug Hellmann中文版
- Hands-On Reinforcement Learning - Sudharsan Ra
- 《DSP思维:Python数字信号处理》LaTe
- Python源码剖析 超清晰版本
- Python学习手册(第四版).rar
- 《Django企业开发实战高效PythonWeb框架
- 《Python强化学习实战》随书代码
-
python的ba
semap库安装包ba semap-1.2. - python使用dlib对人脸识别的范例程序
- 卷积神经网络的Python实现
-
ba
semap-1.2.1-cp38-cp38m-win_amd64.whl - 《Python程序设计基础》习题答案与分
- 机器学习分类算法分析及基于Python的
- Multi-Devices.rar
- Python-20182019校招春招秋招算法NLP深度
- Python金融大数据分析,带目录
- Win10下Gensim 3.8编译版本,词向量训练
- Python计算机视觉编程(含源码+python计
- python机器学习及实践
- Python机器学习实践指南.pdf+代码+数据
- Python 3.6.1+Scrapy 1.1.0rc3
- Python机器学习Sebastian著-带书签
- Learning Python(3rd.Edition.完整书签目录
评论
共有 条评论