dlib python人脸检测 特征点定位
2017-11-20 11:31
761 查看
参考:
1、http://blog.csdn.net/hjimce/article/details/51307886
2、http://dlib.net/
1、http://blog.csdn.net/hjimce/article/details/51307886
2、http://dlib.net/
1、python
人脸检测
# -*- coding: UTF-8 -*- import cv2 import dlib import numpy as np # 根据人脸框bbox,从一张完整图片裁剪出人脸 def getface(): bgrImg = cv2.imread('nba.jpg') print(bgrImg.shape) rgbImg = cv2.cvtColor(bgrImg, cv2.COLOR_BGR2RGB) detector = dlib.get_frontal_face_detector() # img = io.imread('1.jpg') faces = detector(rgbImg, 1) if len(faces) > 0: for face in faces: # face = max(faces, key=lambda rect: rect.width() * rect.height()) [x1, x2, y1, y2] = [face.left(), face.right(), face.top(), face.bottom()] cv2.rectangle(bgrImg,(x1,y1),(x2,y2),(0,255,0),2,cv2.LINE_AA) cv2.imshow("dst",bgrImg) cv2.waitKey(0) cv2.destroyAllWindows() getface()
人脸特征点定位
先从网上下载预训练模型shape_predictor_68_face_landmarks.dat,点击这里找到并下载# -*- coding: UTF-8 -*- import cv2 import dlib import matplotlib.pyplot as plt # 根据人脸框bbox,从一张完整图片裁剪出人脸,并保存问文件名cropimgname # 如果未检测到人脸,那么返回false,否则返回true face_detector = dlib.get_frontal_face_detector() landmark_predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") def geteye_rect(imgpath): bgrImg = cv2.imread(imgpath) if bgrImg is None: return False rgbImg = cv2.cvtColor(bgrImg, cv2.COLOR_BGR2RGB) facesrect = face_detector(rgbImg, 1) if len(facesrect) <= 0: return False for k, d in enumerate(facesrect): shape = landmark_predictor(rgbImg, d) for i in range(68): pt = shape.part(i) plt.plot(pt.x, pt.y, 'ro') plt.imshow(rgbImg) plt.show() geteye_rect("nba.jpg")
2、c++
参考:http://blog.csdn.net/hjimce/article/details/51307886相关文章推荐
- python 3利用Dlib 19.7实现摄像头人脸检测特征点标定
- 深度学习(PYTORCH)-2.python调用dlib提取人脸68个特征点
- Linux下python 与 C++ dlib人脸检测
- Linux下python 与 C++ dlib人脸检测
- python dlib学习(二):人脸特征点标定
- dlib 04 dlib自带demo 基于HOG的人脸特征检测
- 人脸检测原理及示例(OpenCV+Python) haar特征 adaboost
- 人脸检测、提取特征点(dlib下的三个例子)
- Ubuntu下Python之dlib人脸检测
- Dlib人脸特征点检测(速度优化)
- 裸机Ubuntu16.04配置Dlib19.4 (Python人脸检测例子)
- Python 3 利用 Dlib 19.7 实现人脸检测和剪切
- Python-OpenCV人脸检测---直接调用训练好的Harr特征
- 人脸特征点定位与检测
- Haar、pico、npd、dlib等多种人脸检测特征及算法结果比较
- 用dlib和opencv进行不同角度人脸检测及68个关键点提取(Python)
- 结合OpenCV摄像头使用Dlib库进行人脸检测及标注特征点和提取人脸特征-Python
- 裸机Ubuntu16.04配置Dlib19.4 (Python人脸检测例子)
- Dlib人脸特征点检测(速度优化)
- python下通过dlib和opencv实现人脸对齐(包括关键点检测和仿射变换)