Tracks.cpp
Go to the documentation of this file.
1 
18 #include "Tracks.hpp"
19 
20 namespace ISM {
21  Tracks::Tracks(std::vector<ObjectSetPtr> sets) {
22  size_t setIdx = 0;
23  for (ObjectSetPtr& set : sets) {
24  for (ObjectPtr& object : set->objects) {
25  TrackPtr track = getTrackByTypeAndId(object->type, object->observedId);
26  if (!track) {
27  track = TrackPtr(new Track(object->type, object->observedId));
28  tracks.push_back(track);
29 
30  // fill up with empty object pointers
31  for (size_t i = 0; i < setIdx; i++) {
32  track->objects.push_back(ObjectPtr());
33  }
34  }
35 
36  track->objects.push_back(object);
37  }
38  // fill up tracks that had no object in this frame
39  for (TrackPtr& track : tracks) {
40  for (size_t i = track->objects.size(); i <= setIdx; i++) {
41  track->objects.push_back(ObjectPtr());
42  }
43  }
44  setIdx++;
45  }
46 
47  for (TrackPtr& track : tracks) {
48  track->calculateWeight();
49  }
50  }
51 
52  Tracks::Tracks(std::vector<TrackPtr> tracks) {
53  this->tracks = tracks;
54  }
55 
56  TrackPtr Tracks::getTrackByTypeAndId(std::string type, std::string observedId) {
57  for (TrackPtr& track : tracks) {
58  if (track->type == type && track->observedId == observedId) {
59  return track;
60  }
61  }
62 
63  return TrackPtr();
64  }
65 
66  std::vector<ObjectSetPtr> Tracks::toObjectSetVector() {
67  std::vector<ObjectSetPtr> ret;
68  if (tracks.size() > 0) {
69  for (size_t i = 0; i < tracks[0]->objects.size(); i++) {
70  ObjectSetPtr set(new ObjectSet());
71  for (TrackPtr& track : tracks) {
72  if (track->objects[i]) {
73  set->insert(track->objects[i]);
74  }
75  }
76  ret.push_back(set);
77  }
78  }
79 
80  return ret;
81  }
82 
83  void Tracks::replace(std::vector<TrackPtr> eraseTracks, TrackPtr newTrack) {
84  for (TrackPtr& eraseTrack : eraseTracks) {
85  for (size_t i = 0; i < tracks.size(); i++) {
86  TrackPtr track = tracks[i];
87  if (eraseTrack == track) {
88  tracks.erase(tracks.begin() + i);
89  break;
90  }
91  }
92  }
93 
94  tracks.push_back(newTrack);
95  }
96 }
TrackPtr getTrackByTypeAndId(std::string type, std::string observedId)
Definition: Tracks.cpp:56
std::vector< ObjectSetPtr > toObjectSetVector()
Definition: Tracks.cpp:66
std::vector< TrackPtr > tracks
Definition: Tracks.hpp:36
boost::shared_ptr< ObjectSet > ObjectSetPtr
Definition: ObjectSet.hpp:53
Tracks(std::vector< ObjectSetPtr > sets)
Definition: Tracks.cpp:21
void replace(std::vector< TrackPtr > tracks, TrackPtr newTrack)
Definition: Tracks.cpp:83
boost::shared_ptr< Track > TrackPtr
Definition: Track.hpp:55
this namespace contains all generally usable classes.
boost::shared_ptr< Object > ObjectPtr
Definition: Object.hpp:82


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41