当前位置:网站首页>Dlib database face
Dlib database face
2022-06-30 08:03:00 【emplace_ back】
picture
Box marker
import cv2 as cv
import dlib
# open
filename = 'C:/Users/to_bo/Desktop/1.jpg'
img = cv.imread(filename)
# Return to the detector
detector = dlib.get_frontal_face_detector()
# Return to the face box
faces = detector(img, 1)
# Suppose multiple face frames are returned , Traverse in turn
for i, d in enumerate(faces):
# Picture frame
cv.rectangle(
img,
tuple([d.left(), d.top()]),
tuple([d.right(), d.bottom()]),
(0, 255, 255),
2
)
# Output
cv.imshow('img', img)
# end
cv.waitKey(0)
cv.destroyAllWindows()
68 punctuation
import cv2 as cv
import dlib
# open
path = 'C:/Users/to_bo/Desktop/1.jpg'
img = cv.imread(path)
# Return to the detector
detector = dlib.get_frontal_face_detector()
# Return to the face box
faces = detector(img, 1)
# Return to anchor keys
predictor = dlib.shape_predictor(
'C:/Users/to_bo/Desktop/1.dat'
)
# Suppose multiple face frames are returned , Traverse in turn
for face in faces:
# Locate the key points of the face in the frame
shape = predictor(img, face)
# Traverse all of (68) spot , Print out its coordinates , Tagged
for p in shape.parts():
cv.circle(img, (p.x, p.y), 1, (255, 0, 0), -1)
# Output
cv.imshow("image", img)
# end
cv.waitKey(0)
cv.destroyAllWindows()
predictor = dlib.shape_predictor() Key predictor usage
detector = dlib.get_frontal_face_detector() Get the usage of face box
video
import cv2 as cv
import dlib
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(
'C:/Users/to_bo/Desktop/1.dat'
)
cap = cv.VideoCapture(0, cv.CAP_DSHOW)
if not cap.isOpened():
print("Can not open camera")
exit(0)
while True:
ret, frame = cap.read()
if not ret:
print("Can not receive frame")
break
faces = detector(frame, 1)
for face in faces:
shape = predictor(frame, face)
for p in shape.parts():
cv.circle(frame, (p.x, p.y), 2, (0, 255, 0), -1)
cv.imshow('img', frame)
if cv.waitKey(1) & 0xFF == 27:
break
cap.release()
cv.destroyAllWindows()
Add
detector.run() The identification of ( Not exactly )
import cv2 as cv
import dlib
img = cv.imread('C:/Users/to_bo/Desktop/2.jpg')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
detector = dlib.get_frontal_face_detector()
# predictor = dlib.shape_predictor('C:/Users/to_bo/Desktop/1.dat')
faces = detector(gray, 1)
# for face in faces:
# points = predictor(gray, face)
# for p in points.parts():
# cv.circle(img, (p.x, p.y), 1, (0, 255, 0), -1)
# cv.namedWindow('img', cv.WINDOW_NORMAL)
# cv.imshow('img', img)
# cv.waitKey(0)
# cv.destroyWindow('img')
dets, scores, idx = detector.run(img, 1, -1)
for i, d in enumerate(dets):
print("Detection {}, score: {}, face_type:{}".format(
d, scores[i], idx[i]))
if scores[i] > 0.8:
cv.rectangle(img, (d.left(), d.top()), (d.right(), d.bottom()), (0, 255, 255), 2)
cv.putText(
img,
str(scores[i]),
(d.left(), d.bottom()),
cv.FONT_HERSHEY_TRIPLEX,
1,
(0, 255, 0),
2,
cv.LINE_AA
)
cv.namedWindow('img', cv.WINDOW_NORMAL)
cv.imshow('img', img)
cv.waitKey(0)
cv.destroyAllWindows()
from imutils import face_utils
import cv2 as cv
import dlib
from imutils import face_utils
img = cv.imread('./1.jpg')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor('1.dat')
faces = detector(gray, 1)
for face in faces:
shapes = predictor(gray, face)
points = face_utils.shape_to_np(shapes)
img = face_utils.visualize_facial_landmarks(img, points)
for point in points:
cv.circle(img, (point[0], point[1]), 1, (255, 255, 255), -1)
cv.imshow('img', img)
cv.waitKey(0)
cv.destroyAllWindows()
# print(face_utils.FACIAL_LANDMARKS_IDXS)
import cv2 as cv
import dlib
from imutils import face_utils
cap = cv.VideoCapture(0, cv.CAP_DSHOW)
if not cap.isOpened():
print('Can not open')
exit(0)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor('1.dat')
while True:
ret, frame = cap.read()
if not ret:
print('Can not get frame')
break
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
faces = detector(gray, 1)
for face in faces:
shapes = predictor(gray, face)
points = face_utils.shape_to_np(shapes)
frame = face_utils.visualize_facial_landmarks(frame, points)
for point in points:
cv.circle(frame, (point[0], point[1]), 1, (255, 255, 255), -1)
cv.imshow('img', frame)
if cv.waitKey(1) & 0xff == 27:
break
cv.destroyAllWindows()
边栏推荐
- How CRM & PM helps enterprises create optimal sales performance
- November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)
- Development technology sharing of Jingtan NFT digital collection system
- JS代码案例
- 期末複習-PHP學習筆記5-PHP數組
- Arm debug interface (adiv5) analysis (I) introduction and implementation [continuous update]
- Niuke White Moon race 52
- Why don't you know what to do after graduation from university?
- 2021-10-29 [microbiology] qiime2 sample pretreatment form automation script
- Final review -php learning notes 1
猜你喜欢

Do you know the IP protocol?
![November 22, 2021 [reading notes] - bioinformatics and functional genomics (Section 5 of Chapter 5 uses a comparison tool similar to blast to quickly search genomic DNA)](/img/de/7ffcc8d6911c499a9798ac9215c63f.jpg)
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Section 5 of Chapter 5 uses a comparison tool similar to blast to quickly search genomic DNA)

【花雕体验】14 行空板pinpong库测试外接传感器模块(之一)

Deep learning - LSTM

Vulfocus entry target

Simple application of generating function

Final review -php learning notes 4-php custom functions

Efga design open source framework fabulous series (I) establishment of development environment

Armv8 (coretex-a53) debugging based on openocd and ft2232h

鲸探NFT数字臧品系统开发技术分享
随机推荐
Cadence physical library lef file syntax learning [continuous update]
AcrelEMS能效管理平台为高层小区用电安全保驾护航
F12 packet capture is used for the whole process analysis of postman interface test
Arm debug interface (adiv5) analysis (I) introduction and implementation [continuous update]
Self study notes -- use of 74h573
Analysis of cross clock transmission in tinyriscv
Bingbing learning notes: quick sorting
Deep learning vocabulary representation
Tue Jun 28 2022 15:30:29 GMT+0800 (中国标准时间) 日期格式化
Inversion Lemma
你了解IP协议吗?
Introduction to opencv (II): image color space conversion and image saving
Lexicographic order -- full arrangement in bell sound
How CRM & PM helps enterprises create optimal sales performance
NMOS model selection
C. Fishingprince Plays With Array
小程序使用二维码插件
November 16, 2021 [reading notes] - macro genome analysis process
Deep learning -- using word embedding and word embedding features
架构实战营模块 5 作业