第七章触觉感知元素结构理论
2026/7/28 18:49:25
dlib库是一个人脸中很常用的库,用于数据预处理阶段。
dlib库的官方网站是:http://dlib.net/
在官网上,我们主要查看两部分内容,一个是 python api,另一个就是 Python版本的 examples。
举个我常用的小例子吧,比如要做人脸关键点或者属性,需要把人脸部分提取出来,可以这样:
import cv2 import dlib detector = dlib.get_frontal_face_detector() img = cv2.imread('/home/dddzz/worksapce/datasets/lfw/Aaron_Guiel/Aaron_Guiel_0001.jpg') dets = detector(img, 1) for i, d in enumerate(dets): print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format( i, d.left(), d.top(), d.right(), d.bottom()))这样可以获得人脸框的坐标。