当前位置:网站首页>人脸识别框架之dlib
人脸识别框架之dlib
2022-04-23 16:25:00 【andrew P】
1.人脸检测如下
import dlib
from imageio import imread
detector = dlib.get_frontal_face_detector()#检测器
predictor_path = 'shape_predictor_68_face_landmarks.dat'
predictor = dlib.shape_predictor(predictor_path)#预测器
win = dlib.image_window()
path ='111.jpg'
img = imread(path)
win.clear_overlay()
win.set_image(img)
# 1 表示将图片放大一倍,便于检测到更多人脸
dets = detector(img, 1)
print('检测到了 %d 个人脸' % len(dets))
for i, d in enumerate(dets):
print('- %d: Left %d Top %d Right %d Bottom %d' % (i, d.left(), d.top(), d.right(), d.bottom()))
shape = predictor(img, d)
# 第 0 个点和第 1 个点的坐标
print('Part 0: {}, Part 1: {}'.format(shape.part(0), shape.part(1)))
win.add_overlay(shape)
2.生成面部检测器
detector = dlib.get_frontal_face_detector()#检测器
3.生成特征预测器,68维度的
predictor_path = 'shape_predictor_68_face_landmarks.dat'
predictor = dlib.shape_predictor(predictor_path)#预测器
shape_predictor(landmark_model_path)
参数:landmark_model_path:68特征landmarks模型path
官方例子如下:
http://dlib.net/face_alignment.py.html
# Load all the models we need: a detector to find the faces, a shape predictor
# to find face landmarks so we can precisely localize the face
加载我们需要的所有模型:一个用于查找人脸的检测器,一个用于查找人脸标志的形状预测器,这样我们就可以精确定位人脸
4.开始检测
# 1 表示将图片放大一倍,便于检测到更多人脸
dets = detector(img, 1)
5.返回68个特征点
shape = predictor(img, d)
6.将特征点画到原来的图上
for i, d in enumerate(dets):
print('- %d: Left %d Top %d Right %d Bottom %d' % (i, d.left(), d.top(), d.right(), d.bottom()))
shape = predictor(img, d)
# 第 0 个点和第 1 个点的坐标
print('Part 0: {}, Part 1: {}'.format(shape.part(0), shape.part(1)))
win.add_overlay(shape)
结果
版权声明
本文为[andrew P]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_41166909/article/details/124330874
边栏推荐
- volatile的含义以及用法
- Nanny Anaconda installation tutorial
- Sail soft segmentation solution: take only one character (required field) of a string
- JSP learning 3
- homwbrew安装、常用命令以及安装路径
- Day (6) of picking up matlab
- Cloudy data flow? Disaster recovery on cloud? Last value content sharing years ago
- File system read and write performance test practice
- Algorithem_ ReverseLinkedList
- 100 deep learning cases | day 41 - convolutional neural network (CNN): urbansound 8K audio classification (speech recognition)
猜你喜欢
Six scenarios of cloud migration
299. Number guessing game
建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
漫画:什么是IaaS、PaaS、SaaS?
安装Redis并部署Redis高可用集群
How magical is the unsafe class used by all major frameworks?
Sail soft segmentation solution: take only one character (required field) of a string
Government cloud migration practice: Beiming digital division used hypermotion cloud migration products to implement the cloud migration project for a government unit, and completed the migration of n
What is the experience of using prophet, an open source research tool?
299. 猜数字游戏
随机推荐
Unity shader learning
Nacos 详解,有点东西
面试题 17.10. 主要元素
299. Number guessing game
VIM uses vundle to install the code completion plug-in (youcompleteme)
Day (10) of picking up matlab
[key points of final review of modern electronic assembly]
About JMeter startup flash back
Filter usage of spark operator
The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?
Hypermotion cloud migration helped China Unicom. Qingyun completed the cloud project of a central enterprise and accelerated the cloud process of the group's core business system
Win11 / 10 home edition disables the edge's private browsing function
Vim使用Vundle安装代码补全插件(YouCompleteMe)
C language self compiled string processing function - string segmentation, string filling, etc
欣旺达:HEV和BEV超快充拳头产品大规模出货
05 Lua 控制结构
文件系统读写性能测试实战
捡起MATLAB的第(6)天
Questions about disaster recovery? Click here
力扣-198.打家劫舍