1 Star 0 Fork 1

hexuan-boy/shape_predictor_81_face_landmarks

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webcam_record.py 961 Bytes
一键复制 编辑 原始数据 按行查看 历史
Nikolay Feldman 提交于 2018-05-19 16:58 . live video example
import sys
import os
import dlib
import glob
from skimage import io
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (1280, 720))
predictor_path = 'shape_predictor_81_face_landmarks.dat'
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
while(cap.isOpened()):
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
dets = detector(frame, 0)
for k, d in enumerate(dets):
shape = predictor(frame, d)
landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])
for num in range(shape.num_parts):
cv2.circle(frame, (shape.parts()[num].x, shape.parts()[num].y), 3, (0,255,0), -1)
cv2.imshow('frame', frame)
out.write(frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
print("q pressed")
break
cap.release()
out.release()
cv2.destroyAllWindows()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hexuanboy/shape_predictor_81_face_landmarks.git
git@gitee.com:hexuanboy/shape_predictor_81_face_landmarks.git
hexuanboy
shape_predictor_81_face_landmarks
shape_predictor_81_face_landmarks
master

搜索帮助