forked from Mathanraj-Sharma/OpenCV_Sample_Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21_digital_makeup.py
33 lines (22 loc) · 1.2 KB
/
21_digital_makeup.py
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
import face_recognition
from PIL import Image, ImageDraw
image = face_recognition.load_image_file('/home/mr/Desktop/face_rec/thushangi.jpg')
# getting all facial landmarks in all the faces in the image
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')
# making eyebrow darker
d.polygon(face_landmarks['left_eyebrow'], fill = (68, 54, 39, 255))
d.polygon(face_landmarks['right_eyebrow'], fill = (68, 54, 39, 255))
d.line(face_landmarks['left_eyebrow'], fill = (68, 54, 39, 255), width = 5)
d.line(face_landmarks['left_eyebrow'], fill = (68, 54, 39, 255), width = 5)
# Adding lipstick
d.polygon(face_landmarks['top_lip'], fill = (255,0,0,128))
d.polygon(face_landmarks['bottom_lip'], fill = (255,0,0,128))
d.line(face_landmarks['top_lip'], fill = (255,0,0,64), width = 8)
d.line(face_landmarks['bottom_lip'], fill = (255,0,0,64), width = 8)
# adding mascara
d.line(face_landmarks['left_eye']+ [face_landmarks['left_eye'][0]], fill = (0,0,0,125), width = 6)
d.line(face_landmarks['right_eye']+ [face_landmarks['right_eye'][0]], fill = (0,0,0,125), width = 6)
pil_image.show()