|
9 | 9 | from ..updater import Updater |
10 | 10 | from ..hypothesiser.gaussianmixture import GaussianMixtureHypothesiser |
11 | 11 | from ..mixturereducer.gaussianmixture import GaussianMixtureReducer |
12 | | -from ..buffered_generator import BufferedGenerator |
13 | 12 |
|
14 | 13 |
|
15 | 14 | class PointProcessMultiTargetTracker(Tracker): |
@@ -46,6 +45,10 @@ def tracks(self): |
46 | 45 | tracks.add(track) |
47 | 46 | return tracks |
48 | 47 |
|
| 48 | + def __iter__(self): |
| 49 | + self.detector_iter = iter(self.detector) |
| 50 | + return super().__iter__() |
| 51 | + |
49 | 52 | def update_tracks(self): |
50 | 53 | """ |
51 | 54 | Updates the tracks (:class:`Track`) associated with the filter. |
@@ -74,27 +77,26 @@ def update_tracks(self): |
74 | 77 | self.extraction_threshold: |
75 | 78 | self.target_tracks[tag] = Track([component], id=tag) |
76 | 79 |
|
77 | | - @BufferedGenerator.generator_method |
78 | | - def tracks_gen(self): |
79 | | - for time, detections in self.detector: |
80 | | - # Add birth component |
81 | | - self.birth_component.timestamp = time |
82 | | - self.gaussian_mixture.append(self.birth_component) |
83 | | - # Perform GM Prediction and generate hypotheses |
84 | | - hypotheses = self.hypothesiser.hypothesise( |
85 | | - self.gaussian_mixture.components, |
86 | | - detections, |
87 | | - time |
88 | | - ) |
89 | | - # Perform GM Update |
90 | | - self.gaussian_mixture = self.updater.update(hypotheses) |
91 | | - # Reduce mixture - Pruning and Merging |
92 | | - self.gaussian_mixture.components = \ |
93 | | - self.reducer.reduce(self.gaussian_mixture.components) |
94 | | - # Update the tracks |
95 | | - self.update_tracks() |
96 | | - self.end_tracks() |
97 | | - yield time, self.tracks |
| 80 | + def __next__(self): |
| 81 | + time, detections = next(self.detector_iter) |
| 82 | + # Add birth component |
| 83 | + self.birth_component.timestamp = time |
| 84 | + self.gaussian_mixture.append(self.birth_component) |
| 85 | + # Perform GM Prediction and generate hypotheses |
| 86 | + hypotheses = self.hypothesiser.hypothesise( |
| 87 | + self.gaussian_mixture.components, |
| 88 | + detections, |
| 89 | + time |
| 90 | + ) |
| 91 | + # Perform GM Update |
| 92 | + self.gaussian_mixture = self.updater.update(hypotheses) |
| 93 | + # Reduce mixture - Pruning and Merging |
| 94 | + self.gaussian_mixture.components = \ |
| 95 | + self.reducer.reduce(self.gaussian_mixture.components) |
| 96 | + # Update the tracks |
| 97 | + self.update_tracks() |
| 98 | + self.end_tracks() |
| 99 | + return time, self.tracks |
98 | 100 |
|
99 | 101 | def end_tracks(self): |
100 | 102 | """ |
|
0 commit comments