您的位置:首页 > 编程语言 > Python开发

基础知识(十三)dlib python人脸检测

2016-05-03 21:28 627 查看
import  cv2
import  dlib
import numpy as np
#根据人脸框bbox,从一张完整图片裁剪出人脸
def getface():
bgrImg = cv2.imread('1.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:
face=max(faces, key=lambda rect: rect.width() * rect.height())
[x1,x2,y1,y2]=[face.left(),face.right(),face.top(),face.bottom()]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: