dlib的安装(windows)
- 安装cmake,在官网下载最新的zar,然后解压,添加环境变量,即可。
- 安装dlib,pip install dlib
注意:要先安装好anaconda 和 VS2017
dlib人脸识别例子
import dlib
cnn_face_detector = dlib.cnn_face_detection_model_v1("mmod_human_face_detector.dat")
f = "./data/400_3.bmp"
img = dlib.load_rgb_image(f)
dets = cnn_face_detector(img,1)
print("Num of faces detected: {}".format(len(dets)))
for i, d in enumerate(dets):
print("detection {}: left:{} top:{} right:{} bottom:{} confidence:{}".format(
i, d.rect.left(), d.rect.top(), d.rect.right(), d.rect.bottom(), d.confidence))
rects = dlib.rectangles()
rects.extend([d.rect for d in dets])
win = dlib.image_window()
win.clear_overlay()
win.set_image(img)
win.add_overlay(rects)
dlib.hit_enter_to_continue()
参考链接
官网: cnn_face_detector