-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreadDataset.py
More file actions
77 lines (47 loc) · 1.51 KB
/
readDataset.py
File metadata and controls
77 lines (47 loc) · 1.51 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 23:54:28 2020
@author: aguasharo
"""
def get_y_train(train_samples):
# Changes a gesture into a code
y_train = []
for sample in train_samples:
y = train_samples[sample]['gestureName']
if y == 'noGesture':
code = 1
elif y == 'fist':
code = 2
elif y == 'waveIn':
code = 3
elif y == 'waveOut':
code = 4
elif y == 'open':
code = 5
elif y == 'pinch':
code = 6
y_train.append(code)
return y_train
def code2gesture(code):
# This function returns the gesture name from code
if code == 1:
label = 'noGesture'
elif code == 2:
label = 'fist'
elif code == 3:
label = 'waveIn'
elif code == 4:
label = 'waveOut'
elif code == 5:
label = 'open'
elif code == 6:
label = 'pinch'
return label
def code2gesture_labels(vector_labels_prev):
# This function returns a prediction vector with gesture names
v2 = []
for window in vector_labels_prev:
vec_prev = code2gesture(window)
v2.append(vec_prev)
return v2