Dlib + python + opencv 实时人脸68特征点提取
2017-12-18 16:14
656 查看
1.安装libboost:
进入python环境,输入:
3.安装skimage:
非常简洁的代码:
sudo apt-get install libbost-python-dev cmake2.安装dlib。首先去官网(http://dlib.net/)下载dlib,解压后在根目录可以看到setup.py文件,在此目录下运行:
sudo python setup.py install如没有添加权限可能会出现“error: can't create or remove files”这样的错误。
进入python环境,输入:
import dlib无异常提示,则安装成功。
3.安装skimage:
sudo apt-get install python-skimage4.下载 landmark的模型:http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
非常简洁的代码:
import cv2 import dlib cap=cv2.VideoCapture(0) predictor_path = "shape_predictor_68_face_landmarks.dat" predictor = dlib.shape_predictor(predictor_path) detector = dlib.get_frontal_face_detector() while True: _,frame=cap.read() # Ask the detector to find the bounding boxes of each face. The 1 in the # second argument indicates that we should upsample the image 1 time. This # will make everything bigger and allow us to detect more faces. dets = detector(frame, 1) if len(dets) != 0: # Get the landmarks/parts for the face in box d. shape = predictor(frame, dets[0]) for p in shape.parts(): cv2.circle(frame, (p.x, p.y), 3, (0,0,0), -1) cv2.imshow('video',frame) if cv2.waitKey(1)&0xFF==27: break cap.release() cv2.destroyAllWindows()如果要识别多个人脸,将
if len(dets) != 0:改为:
for i in range(len(dets)):PS:如遇报错:RuntimeError: Unsupported image type, must be 8bit gray or RGB image,可能是摄像头没装好,我用的USB摄像头,有个地方接触不良,会经常遇到这样的报错。
相关文章推荐
- Dlib提取人脸特征点(68点,opencv画图)
- 深度学习(PYTORCH)-2.python调用dlib提取人脸68个特征点
- 用dlib和opencv进行不同角度人脸检测及68个关键点提取(Python)
- Dlib+opencv实时提取人脸轮廓(windows环境下//Dlib配置入门)
- 结合OpenCV摄像头使用Dlib库进行人脸检测及标注特征点和提取人脸特征-Python
- 4、dlib学习笔记--提取人脸特征点(68点,opencv画图)
- Dlib提取人脸特征点(68点,opencv画图)
- python dlib学习(二):人脸特征点标定
- python opencv人脸检测提取及保存
- 人脸识别特征提取(LBP)及其opencv实现
- SIFT图像特征提取 python3.4 + opencv3.1.0代码
- Python 3 利用 Dlib 实现摄像头实时人脸识别
- C++之Dlib库实现68个特征点人脸的提取(根据Dlib官网例程改写)
- LBP特征提取(opencv3&python)
- opencv教程(基于python)----图象的特征与提取
- python 3利用Dlib 19.7实现摄像头人脸检测特征点标定
- python 借助opencv实现Gabor滤波特征提取
- python版opencv摄像头人脸实时检测方法
- opencv-python 提取sift特征并匹配
- 【Python+OpenCV】图片局部区域像素值处理(改进版)-一种特征提取方法