|
4 | 4 |
|
5 | 5 | @author: Shamir
|
6 | 6 | """
|
7 |
| -#============================================================================== |
8 |
| -# |
9 |
| -# for i in range(len(os.listdir(sourcePath))): # we have 6 files corresponding to 6 gestures |
10 |
| -# gesture = os.listdir(sourcePath)[i] # Jab, Uppercut, Throw, Jets, Block, Asgard |
11 |
| -# dataset = os.listdir(sourcePath + gesture)[0] # Dataset: Train = 0, Cross Validation = 1, Test = 2 |
12 |
| -# copy = False |
13 |
| -# variance_array = [] |
14 |
| -# |
15 |
| -# for k in range(len(os.listdir(sourcePath + gesture + backslash + dataset))): |
16 |
| -# sensor = os.listdir(sourcePath + gesture + backslash + dataset)[k] # Sensor15, Sensor16, Sensor17, Sensor18, Sensor19 |
17 |
| -# sensorFolder = os.listdir(sourcePath + gesture + backslash + dataset + backslash + sensor) # 1.csv ... 4.csv |
18 |
| -# |
19 |
| -# for l in range(len(sensorFolder)): |
20 |
| -# csvfile = sourcePath + gesture + backslash + dataset + backslash + sensor + backslash + sensorFolder[l] # full filepath |
21 |
| -# readFile = pandas.read_csv(csvfile, header = None) |
22 |
| -# readFile.values[1:] = readFile.values[1:].astype(float) |
23 |
| -# |
24 |
| -# variance = ['Var_' + sensor[6:] + '_' + readFile.values[0,0]] |
25 |
| -# print variance |
26 |
| -# variance = np.asarray(variance) |
27 |
| -# |
28 |
| -# if copy == True: |
29 |
| -# for m in range(1, len(readFile.values)): # |||len(readFile.values)||| |
30 |
| -# ## need to add code to check if number_of_rows matches |
31 |
| -# Var = np.var(readFile.values[m]) |
32 |
| -# variance = np.vstack((variance, Var)) |
33 |
| -# variance_array = np.hstack((variance_array, variance)) |
34 |
| -# else: |
35 |
| -# for m in range(1, len(readFile.values)): |
36 |
| -# Var = np.var(readFile.values[m]) |
37 |
| -# variance = np.vstack((variance, Var)) |
38 |
| -# #covariance_array = np.zeros([len(readFile1.values),1]) |
39 |
| -# variance_array = variance.copy() |
40 |
| -# copy = True |
41 |
| -# if i == 0: |
42 |
| -# fullFile = DataFrame(variance_array) |
43 |
| -# else: |
44 |
| -# variance_array = DataFrame(variance_array) |
45 |
| -# fullFile = pandas.concat([fullFile, variance_array], join = 'inner') |
46 |
| -#============================================================================== |
47 |
| -#============================================================================== |
48 |
| -# |
49 |
| -# |
50 |
| -# for i in range(len(os.listdir(sourcePath))): # we have 6 files corresponding to 6 gestures |
51 |
| -# gesture = os.listdir(sourcePath)[i] # Jab, Uppercut, Throw, Jets, Block, Asgard |
52 |
| -# dataset = os.listdir(sourcePath + gesture)[0] # Train, Cross Validation, Test |
53 |
| -# copy = False |
54 |
| -# velocity_array = [] |
55 |
| -# |
56 |
| -# for k in range(len(os.listdir(sourcePath + gesture + backslash + dataset))): |
57 |
| -# sensor = os.listdir(sourcePath + gesture + backslash + dataset)[k] |
58 |
| -# sensorFolder = os.listdir(sourcePath + gesture + backslash + dataset + backslash + sensor) |
59 |
| -# |
60 |
| -# for l in range(len(sensorFolder)): |
61 |
| -# csvfile = sourcePath + gesture + backslash + dataset + backslash + sensor + backslash + sensorFolder[l] # full filepath |
62 |
| -# readFile = pandas.read_csv(csvfile, header = None) |
63 |
| -# readFile.values[1:] = readFile.values[1:].astype(float) |
64 |
| -# |
65 |
| -# velocity = ['Vel_' + sensor[6:] + '_' + readFile.values[0,0]] |
66 |
| -# print velocity |
67 |
| -# velocity = np.asarray(velocity) |
68 |
| -# distance = 0 |
69 |
| -# time = np.shape(readFile.values)[1] / frequency_quat |
70 |
| -# |
71 |
| -# if copy == True: |
72 |
| -# for m in range(1, len(readFile.values)): # for every two files |
73 |
| -# for n in range(np.shape(readFile.values)[1] - 1): |
74 |
| -# ## need to add code to check if number_of_rows matches |
75 |
| -# next_index = n + 1 |
76 |
| -# distance += euclidean(readFile.values[m, n], readFile.values[m, next_index]) |
77 |
| -# vel = distance/time |
78 |
| -# velocity = np.vstack((velocity, vel)) |
79 |
| -# velocity_array = np.hstack((velocity_array, velocity)) |
80 |
| -# else: |
81 |
| -# for m in range(1, len(readFile.values)): # len(readFile.values) |
82 |
| -# for n in range(np.shape(readFile.values)[1] - 1): |
83 |
| -# next_index = n + 1 |
84 |
| -# distance += euclidean(readFile.values[m, n], readFile.values[m, next_index]) |
85 |
| -# vel = distance/time |
86 |
| -# velocity = np.vstack((velocity, vel)) |
87 |
| -# velocity_array = velocity.copy() |
88 |
| -# copy = True |
89 |
| -# # Create complete file structure/dataframe |
90 |
| -# if i == 0: |
91 |
| -# fullFile3 = DataFrame(velocity_array) |
92 |
| -# else: |
93 |
| -# velocity_array = DataFrame(velocity_array) |
94 |
| -#============================================================================== |
95 |
| -#============================================================================== |
96 |
| -# fullFile3 = pandas.concat([fullFile3, velocity_array], join = 'inner') |
97 |
| -# |
98 |
| -# |
99 |
| -#============================================================================== |
100 |
| -#============================================================================== |
101 | 7 |
|
102 | 8 | def CalculateValidData():
|
103 | 9 | # Calculate the number of missing values in the array
|
@@ -157,7 +63,7 @@ def CalculateValidData():
|
157 | 63 | #print '1st catch (copy = True) at file, m, n = ', csvfile[-6:], m, n
|
158 | 64 | break
|
159 | 65 |
|
160 |
| - valid_data = CalculateValidData() - 60 # Exclude missing values (we exclude 6 more values to remain within a safer margin) |
| 66 | + valid_data = CalculateValidData() # Exclude missing values (we exclude 6 more values to remain within a safer margin) |
161 | 67 | time = valid_data / frequency_euc
|
162 | 68 |
|
163 | 69 | precessionVelocity = precession/time
|
@@ -218,7 +124,7 @@ def CalculateValidData():
|
218 | 124 | #print '1st catch (copy = False) at print file, m, n = ', csvfile[-6:], m, n
|
219 | 125 | continue
|
220 | 126 |
|
221 |
| - valid_data = CalculateValidData() - 60 |
| 127 | + valid_data = CalculateValidData() |
222 | 128 | time = valid_data / frequency_euc
|
223 | 129 |
|
224 | 130 | precessionVelocity = precession/time
|
|
0 commit comments