-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathvisualize.py
More file actions
26 lines (19 loc) · 797 Bytes
/
Copy pathvisualize.py
File metadata and controls
26 lines (19 loc) · 797 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
import cv2
import numpy as np
from preprocess.data_generator import label_generator
def visualize(img, prob, key):
index = 0
# preprocess
img = np.asarray(img, dtype=np.uint8)
prob = prob.squeeze()
key = key.squeeze()
color = [(15, 15, 240), (15, 240, 155), (240, 155, 15), (240, 15, 155), (240, 15, 240)]
for c, p in enumerate(prob):
if p > 0.5:
img = cv2.circle(img, (int(key[index]), int(key[index + 1])), radius=5, color=color[c], thickness=-2)
index = index + 2
cv2.imshow('Unified Gesture & Fingertips Detection', img)
cv2.waitKey(0)
if __name__ == '__main__':
image, probability, keypoints = label_generator(directory='./dataset/', dtype='train', sample=0)
visualize(img=image, prob=probability, key=keypoints)