资源简介
压缩包中含有【人眼识别+眨眼识别】源代码以及详细使用教程,利用pyrhon+opencv在ubuntu上运行,实现实时的检测,windows环境的配置需要自己在网上找相关教程。。之前上传的资源缺少一个自带的库
代码片段和文件信息
# 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
............此处省略45个文件信息
相关资源
- ABAQUS Python二次开发攻略+pdf+源代码
- Python语言程序设计(北京理工大学)
- 代码:Python+TensorFlow+PyQt实现手写体数
- python(numpy scipy matplotlib sklearn)安装
- python2和python3版本可用的OpenCV安装包
- 基于ArcGIS的Python编程秘笈(第2版)
- 21天学通Python高清Pdf+源代码+PPT
- Python-简单快速实时可定制的机器学习
- python爬取漏洞库.zip
- python算法与数据结构三本教材书籍推
- python神经网络中英文代码.zip
- python3面向对象编程 pdf文件
- 飞机大战python源码及游戏
- 数据结构与算法:Python语言描述 完整
- Python语言程序设计 梁勇著 李娜译
- python程序设计第二版.pdf
- OpenCV+Python+Dlib面部标定、眨眼和疲劳
- PYTHON数据可视化编程实战以及中文P
- CBIR图像检索系统
- 零基础学PYTHON全彩版完整版PDF2 2-2
- Easy Python Decompiler v1.3.2
- 2015新书-Python高手之路英文原版-完整
- python学习用到的几本书打包
- OpenCV 3.x with Python By Example(2nd) 无水
- Python+Spark 2.0+Hadoop机器学习与大数据实
- Python+Spark 2.0+Hadoop机器学习与大数据实
- python爬虫开发与项目实战
- 面向ArcGIS的Python脚本编程美国Paul A.
- python爬虫项目开发实战+源代码
- python 经典入门+进阶书籍打包 中英文
评论
共有 条评论