当前位置:网站首页>Face key point detection
Face key point detection
2022-07-19 03:08:00 【HySmiley】
Open source libraries have dlib
install :https://pypi.org/simple/dlib/ , After downloading pip install
Model download :Index of /files
1、dlib5 spot
Left and right canthus and middle of the person 5 spot .
import dlib
import numpy as np
import cv2
import time
predictor_path = '../model/shape_predictor_5_face_landmarks.dat'
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
start_time = time.time()
frame = cv2.imread("../image/ab.jpg")
img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
dets = detector(img, 1)
print(dets)
for index, det in enumerate(dets):
right_top = (det.right(), det.top())
left_bottom = (det.left(), det.bottom())
# Picture part detection frame
# cv2.rectangle(frame, right_top, left_bottom, (255, 0, 0), 2)
print(right_top,left_bottom)
# Facial feature point detection
shape = predictor(img, det)
landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])
for idx, point in enumerate(landmarks):
# 68 The coordinates of point
pos = (point[0, 0], point[0, 1])
cv2.circle(frame, pos, 5, (0, 0, 255), -1)
cv2.putText(frame,str(idx),pos,cv2.FONT_HERSHEY_COMPLEX,0.6,(0,0,255),1)
cv2.imwrite('kp2.jpg',frame)
cv2.imshow('res',frame)
cv2.waitKey()
2、dlib68 spot
It basically contains the key points of the face area , But there are no key points in the forehead area and only the upper edge of the eyebrow .
import dlib
import numpy as np
import cv2
import time
predictor_path = '../model/shape_predictor_68_face_landmarks.dat'
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
start_time = time.time()
frame = cv2.imread("../image/ab.jpg")
img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
dets = detector(img, 1)
print(dets)
for index, det in enumerate(dets):
right_top = (det.right(), det.top())
left_bottom = (det.left(), det.bottom())
# Picture part detection frame
# cv2.rectangle(frame, right_top, left_bottom, (255, 0, 0), 2)
print(right_top,left_bottom)
# Facial feature point detection
shape = predictor(img, det)
landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])
for idx, point in enumerate(landmarks):
# 68 The coordinates of point
pos = (point[0, 0], point[0, 1])
cv2.circle(frame, pos, 5, (0, 0, 255), -1)
cv2.putText(frame,str(idx),pos,cv2.FONT_HERSHEY_COMPLEX,0.6,(0,0,255),1)
cv2.imwrite('kp2.jpg',frame)
cv2.imshow('res',frame)
cv2.waitKey()
3、 dlib81 spot
Comparison 68 spot , More 13 Points are distributed in the forehead area , But the accuracy of the point is not too high .
import dlib
import numpy as np
import cv2
import time
predictor_path = '../model/shape_predictor_81_face_landmarks.dat'
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
start_time = time.time()
frame = cv2.imread("../image/ab.jpg")
img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
dets = detector(img, 1)
print(dets)
for index, det in enumerate(dets):
right_top = (det.right(), det.top())
left_bottom = (det.left(), det.bottom())
# Picture part detection frame
# cv2.rectangle(frame, right_top, left_bottom, (255, 0, 0), 2)
print(right_top,left_bottom)
# Facial feature point detection
shape = predictor(img, det)
landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])
for idx, point in enumerate(landmarks):
# 68 The coordinates of point
pos = (point[0, 0], point[0, 1])
cv2.circle(frame, pos, 5, (0, 0, 255), -1)
cv2.putText(frame,str(idx),pos,cv2.FONT_HERSHEY_COMPLEX,0.6,(0,0,255),1)
cv2.imwrite('kp2.jpg',frame)
cv2.imshow('res',frame)
cv2.waitKey()
边栏推荐
- The place where the dream begins ---- first knowing C language
- [face recognition] face recognition based on histogram histogram with matlab code
- 快照:数据快照(数据兜底方式)
- Letv a plus de 400 employés? Le jour de l'immortel sans patron, les autorités ont répondu...
- ncnn param文件及bin模型可视化解析
- 【单片机仿真】(二十一)DB(Define Byte)— 定义字节
- [MCU simulation] (XIX) introduction to assembly, assembly instructions, pseudo instructions
- 【单片机仿真】(五)寻址方式 — 立即寻址与寄存器间接寻址
- ncnn paramdict&modelbin
- 2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
猜你喜欢

Can't access this website can't find DNS address DNS_ PROBE_ What about started?

yolov5 opencv DNN 推理

Advanced usage of the responsibility chain pattern

PyTorch最佳实践和代码模板

JDBC connection to MySQL database

【NoSQL】NoSQL之redis配置与优化(简单操作)
![[NoSQL] redis master-slave, sentinel, cluster](/img/69/37b80398617040984b006d3d7b71b9.png)
[NoSQL] redis master-slave, sentinel, cluster

快照:数据快照(数据兜底方式)

乐视还有400多位员工?过着没有老板的神仙日子 官方出来回应了...

【NoSQL】redis高可用和持久化
随机推荐
内置键盘连续444
yolov6 学习初篇
GFS distributed file system
[MCU simulation] (XVIII) control transfer instructions - empty operation instructions
Tools and methods - Excel plug-in xltools
【NoSQL】NoSQL之redis配置与优化(简单操作)
mysqldump: [Warning] Using a password on the command line interface can be insecure.
【MySQL】MHA高可用
4年开发二面美团最终败给:volatile关键字作用和原理这道面试题
MySQL master-slave replication + read write separation
Go语言 实现发送短信验证码 并登录
通过Dao投票STI的销毁,SeekTiger真正做到由社区驱动
From the perspective of MySQL architecture, how does an SQL statement execute?
半年时间的思考
[MCU simulation] (VIII) instruction system - data transmission instruction
你能用到的Mysql常用命令
while 循环
Mysql多表查询
人脸检测几种方法
Specifications、多表查询基础