pyhon3.7.1利用dlib进行68人脸特征点检测

pyhon3.7.1利用dlib进行68人脸特征点检测

** 安装opencv-python**

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

安装cmake

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple cmake

安装scikit-image

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-image

安装boost

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple boost

从此处链接下载dlib安装和对应dlib模型提取码为rbq4
dlib-19.17.99-cp37-cp37m-win_amd64.whl

进入下载的文件夹直接安装dlib

pip install dlib-19.17.99-cp37-cp37m-win_amd64.whl

结果显示成功

(test1) C:\Users\86153\Desktop\dlib人脸识别>pip install dlib-19.17.99-cp37-cp37m-win_amd64.whl
Processing c:\users\86153\desktop\dlib人脸识别\dlib-19.17.99-cp37-cp37m-win_amd64.whl
Installing collected packages: dlib
Successfully installed dlib-19.17.99

下载一张小肥肥的照片
pyhon3.7.1利用dlib进行68人脸特征点检测_第1张图片

下面直接运行68Featurepoints

import cv2
import dlib
detector = dlib.get_frontal_face_detector()
img = cv2.imread(r'xiaofeifei.jpg')
img_gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
predictor = dlib.shape_predictor(r'shape_predictor_68_face_landmarks.dat')
faces = detector(img_gray, 1)
for face in faces:
    shape = predictor(img, face)  # 寻找人脸的68个标定点
    # 遍历所有点,打印出其坐标,并圈出来
    for pt in shape.parts():
        pt_pos = (pt.x, pt.y)
        cv2.circle(img, pt_pos, 2, (0, 0, 255), -1)
cv2.imshow("img",img)
cv2.waitKey(10000)

将dlib模型和小肥肥照片以及68特征点识别程序放在一个文件夹中,或者自己更改相应路径
pyhon3.7.1利用dlib进行68人脸特征点检测_第2张图片

运行然后,显示效果
pyhon3.7.1利用dlib进行68人脸特征点检测_第3张图片

点赞,收藏,谢!

你可能感兴趣的:(python,人脸识别,dlib)