-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverlay.py
More file actions
142 lines (105 loc) · 4.12 KB
/
overlay.py
File metadata and controls
142 lines (105 loc) · 4.12 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import cv2
import numpy as np
import config
# Utils
def circularMask(h,w, cy, cx, r):
x = np.arange(0, w)
y = np.arange(0, h)
return (x[np.newaxis,:]-cx)**2 + (y[:,np.newaxis]-cy)**2 < r**2
font = cv2.FONT_HERSHEY_SIMPLEX
gap = 0
scale = config.scale
h = config.h
w = config.w
# h = 360
# w = 390
W = int(w*.6)
H = int(h*.6)
atkW = int((w-W)/2)
atkH = int((h-H)/2)
maskW = int(200*scale)
lMask = np.array([np.arange(maskW, 0, -0.5) for _ in range(0, h)])
rMask = np.array([np.arange(0, maskW, 0.5) for _ in range(0, h)])
uMask = np.array([np.arange(maskW, 0, -1) for _ in range(0, w)]).T
dMask = np.array([np.arange(0, maskW, 1) for _ in range(0, w)]).T
a_rMask = np.array([np.arange(0, maskW, 1) for _ in range(0, h-2*atkH)])
a_lMask = np.array([np.arange(maskW, 0, -1) for _ in range(0, h-2*atkH)])
a_dMask = np.array([np.arange(0, maskW, 1) for _ in range(0, w-2*atkW)]).T
a_uMask = np.array([np.arange(maskW, 0, -1) for _ in range(0, w-2*atkW)]).T
a_jabMask = circularMask(h,w, int(h/3), int(w/1.5), int(maskW/2))
b_jabMask = circularMask(h,w, int(h/3), int(w/3), int(maskW/2))
def putText(frame, text, coords, color, scale = 1):
coords = (int(coords[0]*w), int(coords[1]*h))
cv2.putText(frame, text, coords, font, scale, color, 2, cv2.LINE_AA)
def maskLeft(frame, multiplyer=1):
frame[:, 0:maskW*2, 1] = frame[:, 0:maskW*2, 1] + (lMask * multiplyer)
return np.clip(frame, 0, 255)
def maskRight(frame, multiplyer=1):
frame[:, w-maskW*2:w, 1] = frame[:, w-maskW*2:w, 1] + (rMask * multiplyer)
return np.clip(frame, 0, 255)
def maskUp(frame):
frame[0:maskW, :, 1] = frame[0:maskW, :, 1] + uMask
return np.clip(frame, 0, 255)
def maskDown(frame, color=1):
frame[h-maskW:h, :, color] = frame[h-maskW:h, :, color] + dMask
return np.clip(frame, 0, 255)
# Attack Masks
def maskRight_AtkR(frame):
frame[atkH:h-atkH, w-(gap+maskW):w-gap, 2] = frame[atkH:h-atkH, w-(gap+maskW):w-gap, 2] + a_rMask
return np.clip(frame, 0, 255)
def maskRight_AtkL(frame):
frame[atkH:h-atkH, gap:gap+maskW, 2] = frame[atkH:h-atkH, gap:gap+maskW, 2] + a_lMask
return np.clip(frame, 0, 255)
def maskRight_AtkU(frame):
frame[0:maskW, atkW:w-atkW, 2] = frame[0:maskW, atkW:w-atkW, 2] + a_uMask
return np.clip(frame, 0, 255)
def maskRight_AtkD(frame):
frame[h-maskW:h, atkW:w-atkW, 2] = frame[h-maskW:h, atkW:w-atkW, 2] + a_dMask
return np.clip(frame, 0, 255)
def maskRight_jab(frame):
frame[a_jabMask, 2] = frame[a_jabMask, 2] + 150
return np.clip(frame, 0, 255)
# Special Masks
def maskLeft_AtkR(frame):
frame[atkH:h-atkH, w-(gap+maskW):w-gap, 0] = frame[atkH:h-atkH, w-(gap+maskW):w-gap, 0] + a_rMask
return np.clip(frame, 0, 255)
def maskLeft_AtkL(frame):
frame[atkH:h-atkH, gap:gap+maskW, 0] = frame[atkH:h-atkH, gap:gap+maskW, 0] + a_lMask
return np.clip(frame, 0, 255)
def maskLeft_AtkU(frame):
frame[0:maskW, atkW:w-atkW, 0] = frame[0:maskW, atkW:w-atkW, 0] + a_uMask
return np.clip(frame, 0, 255)
def maskLeft_AtkD(frame):
frame[h-maskW:h, atkW:w-atkW, 0] = frame[h-maskW:h, atkW:w-atkW, 0] + a_dMask
return np.clip(frame, 0, 255)
def maskLeft_jab(frame):
frame[b_jabMask, 0] = frame[b_jabMask, 0] + 150
return np.clip(frame, 0, 255)
def maskPointer(frame, coords, color=1):
x,y = coords
x = int(w*x)
x = w - x
y = int(h*y)
d = int(maskW/4)
frame[y-d:y+d, x-d:x+d, color] = frame[y-d:y+d, x-d:x+d, color] + 150
return frame
# Don't show masks
if not config.DEBUG:
def putText(frame, text, coords, color, scale = 2): pass
def maskLeft(frame, multiplyer=1): pass
def maskRight(frame, multiplyer=1): pass
def maskUp(frame): pass
def maskDown(frame, color=1): pass
def maskRight_AtkR(frame): pass
def maskRight_AtkL(frame): pass
def maskRight_AtkU(frame): pass
def maskRight_AtkD(frame): pass
def maskLeft_AtkR(frame): pass
def maskLeft_AtkL(frame): pass
def maskLeft_AtkU(frame): pass
def maskLeft_AtkD(frame): pass
def maskRight_jab(frame): pass
def maskLeft_jab(frame): pass
def maskPointer(frame, coords, color=1): pass
if __name__ == "__main__":
print()