-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathface_alignment.py
More file actions
34 lines (28 loc) · 815 Bytes
/
Copy pathface_alignment.py
File metadata and controls
34 lines (28 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# coding=utf-8
"""
light
20180202
人脸对齐
"""
import dlib
import cv2
from face_features import FaceFeatures
class FaceAlignment(FaceFeatures):
def alignment_face(self, features):
image = dlib.get_face_chip(self.img, features)
return image
def jitter_face(self, image):
jittered_images = dlib.jitter_image(image, num_jitters=5)
for image in jittered_images:
self.show(image, 'jitter_face')
cv2.waitKey(0)
if __name__ == '__main__':
f = FaceAlignment()
f.load_img('data/frontal/0017.jpg')
f.show(name='src')
faces = f.detect_face()
for face in faces:
face_img = f.alignment_face(f.detect_features(face['position']))
f.show(face_img, 'alignment_face')
cv2.waitKey(0)
f.jitter_face(face_img)