1.装置 face_recognition

这个face_recognition 是一个很简略的人脸识别库 ,是在dlib框架(蕴含机器学习算法和工具的现代化工具包)上做的整合

第一步装置这俩pip install Cmakepip install boost

而后就要装置 dlib Windows上装置dlib容易出问题 能够间接装置 .whl文件
留神:这个whl文件 要跟python配套 然而当初这个whl文件高版本根本没进去 我前两天装的python3.11找不到对应whl文件 又从新装的python3.8 从新配的环境
上面的 对应3.8的dlib..whl文件
链接:https://pan.baidu.com/s/1g33E...
提取码:xu0f

第二步  装置whl到你寄存whl文件的文件夹外面  cmd  输出命令pip install dlib-19.19.0-cp38-cp38-win_amd64.whl
第三步 而后就能够欢快的装置装置 face_recognition 了pip install face_recognition

而后就可能欢快的写轮廓检测程序了

2.人脸轮廓检测

# coding=utf-8# 绘制面部轮廓import face_recognitionfrom PIL import Image, ImageDraw# 将图片文件加载到numpy 数组中image = face_recognition.load_image_file("./8.jpg")# 查找图像中所有面部的所有面部特色face_landmarks_list = face_recognition.face_landmarks(image)for face_landmarks in face_landmarks_list:    facial_features = [        'chin', 'left_eyebrow', 'right_eyebrow', 'nose_bridge', 'nose_tip',        'left_eye', 'right_eye', 'top_lip', 'bottom_lip'    ]    pil_image = Image.fromarray(image)    d = ImageDraw.Draw(pil_image)    for facial_feature in facial_features:        d.line(face_landmarks[facial_feature], fill=(255, 255, 255), width=3)    pil_image.show()


这次我大威少能够了 hhhh

三 化妆

间接上代码

# coding=utf-8# 数字化妆类import face_recognitionfrom PIL import Image, ImageDraw# 加载图片到numpy arrayimage = face_recognition.load_image_file("./8.jpg")# 标识脸部特色face_landmarks_list = face_recognition.face_landmarks(image)for face_landmarks in face_landmarks_list:    pil_image = Image.fromarray(image)    d = ImageDraw.Draw(pil_image, 'RGBA')    # 绘制眉毛    d.polygon(face_landmarks['left_eyebrow'], fill=(68, 54, 39, 128))    d.polygon(face_landmarks['right_eyebrow'], fill=(68, 54, 39, 128))    d.line(face_landmarks['left_eyebrow'], fill=(68, 54, 39, 150), width=5)    d.line(face_landmarks['right_eyebrow'], fill=(68, 54, 39, 150), width=5)    # 绘制嘴唇    d.polygon(face_landmarks['top_lip'], fill=(150, 0, 0, 128))    d.polygon(face_landmarks['bottom_lip'], fill=(150, 0, 0, 128))    d.line(face_landmarks['top_lip'], fill=(150, 0, 0, 64), width=8)    d.line(face_landmarks['bottom_lip'], fill=(150, 0, 0, 64), width=8)    # 绘制眼睛    d.polygon(face_landmarks['left_eye'], fill=(255, 255, 255, 30))    d.polygon(face_landmarks['right_eye'], fill=(255, 255, 255, 30))    # 绘制眼线    d.line(face_landmarks['left_eye'] + [face_landmarks['left_eye'][0]],           fill=(0, 0, 0, 110),           width=6)    d.line(face_landmarks['right_eye'] + [face_landmarks['right_eye'][0]],           fill=(0, 0, 0, 110),           width=6)    pil_image.show()



xswl hhh 威少的大红唇

代码学习自:
https://github.com/vipstone/f...
https://github.com/vipstone/f...