|
6 | 6 | import Core.CDataSampler_utils as DSUtils |
7 | 7 |
|
8 | 8 | class CDataSampler: |
9 | | - def __init__(self, storage, batch_size, minFrames, defaults={}, maxT=1.0): |
| 9 | + def __init__(self, storage, batch_size, minFrames, defaults={}, maxT=1.0, cumulative_time=True): |
| 10 | + ''' |
| 11 | + If cumulative_time is True, then time is a cumulative time from the start of the trajectory i.e. [0, 0.1, 0.2, 0.3, ...] |
| 12 | + If cumulative_time is False, then time is a time delta between frames i.e. [0, 0.1, 0.1, 0.1, ...] |
| 13 | + ''' |
10 | 14 | self._storage = storage |
11 | 15 | self._defaults = defaults |
12 | 16 | self._batchSize = batch_size |
13 | 17 | self._maxT = maxT |
14 | 18 | self._minFrames = minFrames |
15 | 19 | self._samples = [] |
16 | 20 | self._currentSample = None |
| 21 | + self._cumulative_time = cumulative_time |
17 | 22 | return |
18 | 23 |
|
19 | 24 | def reset(self): |
@@ -118,6 +123,9 @@ def _prepareT(self, res): |
118 | 123 | pass |
119 | 124 | T = np.insert(T, 0, 0.0) |
120 | 125 | assert len(res) == len(T) |
| 126 | + # T is an array of time deltas like [0, 0.1, 0.1, 0.1, ...], convert it to cumulative time |
| 127 | + if self._cumulative_time: |
| 128 | + T = np.cumsum(T) |
121 | 129 | return T |
122 | 130 |
|
123 | 131 | def _framesFor(self, mainInd, samples, steps, stepsSampling): |
|
0 commit comments