-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
63 lines (49 loc) · 1.36 KB
/
generator.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
62
63
# Heavily based on https://google.github.io/mediapipe/solutions/hands#python-solution-api
import cv2
import time
import gest as gd
import numpy as np
import pickle
if __name__ == "__main__":
fd = 5
bf = int(hw / frame_delay)
mp_hands = gd.MH(buffer_size=buffer_size)
data = {}
nds = 200
hs = ["hello"]
for shape in hs:
d[shape] = []
try:
cap = cv2.VideoCapture(0)
print(f"HI '{hs[csi]}'")
time.sleep(pause_time)
while cap.isOpened():
sc, img = cap.read()
if not success:
print("bye")
continue
w, h, _ = img.shape
res = mp_hands.run(img)
# Store
cs = hs[cur]
try:
data[cur].append(MH.his[-1])
except IndexError:
continue
cv2.imshow('MediaPipe Hands', img)
break
print(hi)
if len(data[cur]) == numd:
cur += 1
if cur == len(hs):
raise AssertionError
else:
time.sleep(fd)
except:
for shape in hs:
print(f"{da.shape[0]} data points for {shape}")
with open(f"data_{shape}.p", 'wb') as f:
pickle.dump(da, f)
MH.close()
cap.release()
raise