-
Notifications
You must be signed in to change notification settings - Fork 0
/
gifgen.py
61 lines (49 loc) · 1.08 KB
/
gifgen.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
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
import cv2, sys
from subprocess import call
template = "servers.png"
locations = [
# HP
(85, 27),
(85, 55),
(85, 84),
(85, 109),
(220, 27),
(220, 55),
(220, 84),
(220, 109),
# Dell
(250, 270),
(250, 305),
(250, 342),
(250, 385),
(430, 270),
(430, 305),
(430, 342),
(430, 385),
]
size = 7
color_working = (0, 255, 0) # BGR
color_broken = (0, 0, 255) # BGR
def genAnimation(broken):
img = cv2.imread(template)
for i in range(0, len(locations)):
if (i + 1) in broken:
continue
cv2.circle(img, locations[i], size, color_working, -1)
cv2.imwrite("tmp1.png", img)
for i in range(0, len(locations)):
if (i + 1) not in broken:
continue
cv2.circle(img, locations[i], size, color_broken, -1)
cv2.imwrite("tmp2.png", img)
call(["convert",
"-delay", "60", "tmp1.png",
"-delay", "60", "tmp2.png",
"output.gif"])
call("ffmpeg -y -i output.gif -pix_fmt yuv420p -r 25 -profile:v baseline output.mp4".split(" "))
return "output.mp4"
if __name__ == "__main__":
broken = []
for i in range(1, len(sys.argv)):
broken.append(int(sys.argv[i]))
genAnimation(broken)