forked from botriot/faceup
/
mapping.coffee
113 lines (95 loc) · 2.27 KB
/
mapping.coffee
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{affine, srt} = require './transforms'
# -- AFFINE
# affine mappings have a list of control points. the first two numbers are
# the x,y coords of a pixel on the overlay image. The next two numbers are
# a point on the destination image (expressed percentage, 0-100). You can
# use the various face.{eye_left,eye_right,nose,mouth_left,...} helpers.
module.exports =
hipster: affine (face) -> [
[138, 80, face.eye_left]
[314, 80, face.eye_right]
]
disguise: affine (face) -> [
[148, 106, face.eye_left]
[282, 106, face.eye_right]
[222, 185, face.nose]
]
phantom: affine (face) -> [
[211, 217, face.eye_left]
[345, 217, face.eye_right]
[278, 296, face.nose]
]
googly: affine (face) -> [
[107, 165, face.eye_left]
[372, 165, face.eye_right]
]
eyepatch: affine (face) -> [
[135, 145, face.eye_left]
[326, 145, face.eye_right]
]
# hipster: srt (face) -> [
# [234.5, 72]
# face.width * 1.1 / 469
# face.roll
# @middle(face.eye_left, face.eye_right)
# ]
mustache: srt (face) -> [
[249, 105]
face.width / 491
face.roll
face.mouth_center
]
beard: srt (face) -> [
[343, 200]
face.width / 650
face.roll
face.mouth_center
]
monocle: srt (face) -> [
[68, 72]
face.width / 256
face.roll
face.eye_right
]
sopa: srt (face) -> [
[64, 19]
face.width / 128
face.roll
face.mouth_center
]
# The original mustachio algorithm
mustache2: srt (face) -> [
[249, 105]
@distance(face.nose, face.mouth_center) / 105
@angle(face.mouth_left, face.mouth_right)
face.mouth_center
]
clown: srt (face, photo) -> [
[108, 111]
face.width * 0.5 / 202
0
face.nose
]
scumbag: affine (face) -> [
[79, 129, face.eye_left]
[137, 120, face.eye_right]
]
jason: affine (face) -> [
[95, 176, face.eye_left]
[223, 208, face.eye_right]
[131, 316, face.mouth_center]
]
batman: affine (face) -> [
[43, 217, face.eye_left]
[121, 207, face.eye_right]
[93, 299, face.mouth_center]
]
disapprove: affine (face) -> [
[160, 178, face.eye_left]
[535, 178, face.eye_right]
]
rohan: affine (face) -> [
[49, 107, face.eye_left]
[135, 107, face.eye_right]
[88, 202, face.mouth_center]
]