|
12 | 12 |
|
13 | 13 | #---- The mocap data class ----
|
14 | 14 | class data:
|
15 |
| - |
| 15 | + |
16 | 16 | timederOrder = 0;
|
17 | 17 | filename = ''
|
18 |
| - |
| 18 | + |
19 | 19 | #--- initializer ---
|
20 |
| - def __init__(self, freq, nMarkers, nFrames, markerNames, data, filename): |
| 20 | + def __init__(self, freq, nMarkers, nCameras, nFrames, markerNames, data, filename, timestamp, trajectoryTypes, header): |
21 | 21 | self.freq = freq
|
22 | 22 | self.nMarkers = nMarkers
|
| 23 | + self.nCameras = nCameras |
23 | 24 | self.nFrames = nFrames
|
24 | 25 | self.markerNames = markerNames
|
25 | 26 | self.data = data
|
26 | 27 | self.filename = filename
|
| 28 | + self.timestamp = timestamp |
| 29 | + self.trajectoryTypes = trajectoryTypes |
| 30 | + self.header = header |
27 | 31 |
|
28 | 32 | #--- class method to read tsv files ---
|
29 | 33 | @classmethod
|
30 | 34 | def readTsv(cls, filename):
|
31 |
| - |
| 35 | + |
32 | 36 | file = open(filename)
|
33 |
| - |
| 37 | + |
34 | 38 | #reading tsv header until marker names line
|
35 | 39 | line = 'asdfasdfa'
|
36 | 40 | while line[0:8] != 'MARKER_N':
|
37 | 41 | line = file.readline()
|
38 |
| - |
| 42 | + |
39 | 43 | if line[0:8] == 'NO_OF_FR':
|
40 |
| - nFrames = int(line.split()[1]) |
| 44 | + nFrames = int(line.split()[1]) |
| 45 | + if line[0:8] == 'NO_OF_CA': |
| 46 | + nCameras = int(line.split()[1]) |
41 | 47 | if line[0:8] == 'NO_OF_MA':
|
42 | 48 | nMarkers = int(line.split()[1])
|
43 | 49 | if line[0:8] == 'FREQUENC':
|
44 |
| - freq = float(line.split()[1]) |
45 |
| - |
46 |
| - #line is now marker names line |
| 50 | + freq = float(line.split()[1]) |
| 51 | + if line[0:8] == 'TIME_STA': |
| 52 | + timestamp = str(line.split()[1:4]) |
| 53 | + |
| 54 | + #reading marker names |
47 | 55 | markerNames = line.split()[1:]
|
48 |
| - |
| 56 | + |
| 57 | + #reading additional lines (not in all QTM-TSV files) |
| 58 | + line = file.readline() |
| 59 | + |
| 60 | + if line[0:8] == 'TRAJECTO': |
| 61 | + trajectoryTypes = str(line.split()[1:]) |
| 62 | + |
| 63 | + line = file.readline() |
| 64 | + |
| 65 | + if line[0:5] == 'Frame': |
| 66 | + header = line.split("\t") |
| 67 | + |
49 | 68 | #the rest is marker data
|
50 |
| - data = np.genfromtxt(file) |
51 |
| - |
| 69 | + data = np.genfromtxt(file, delimiter='\t', invalid_raise = False) |
| 70 | + |
52 | 71 | file.close
|
53 |
| - |
54 |
| - return cls(freq, nMarkers, nFrames, markerNames, data, filename) |
| 72 | + |
| 73 | + return cls(freq, nMarkers, nCameras, nFrames, markerNames, data, filename, timestamp, trajectoryTypes, header) |
55 | 74 |
|
56 | 75 |
|
57 | 76 | #---- A norm data class ---- ### this class should probably be removed see todo comment at the top..
|
58 | 77 | class normData:
|
59 |
| - |
| 78 | + |
60 | 79 | #--- initializer ---
|
61 | 80 | def __init__(self, data):
|
62 | 81 | self.freq = data.freq
|
|
0 commit comments