diff --git a/include/core/processor/track_matrix.h b/include/core/processor/track_matrix.h index 511f22a096d830d898049fa966ad1d63ab42c624..62a6a548edd037bf1f9dfd91c8cdf7014f4de70d 100644 --- a/include/core/processor/track_matrix.h +++ b/include/core/processor/track_matrix.h @@ -63,12 +63,12 @@ typedef map<size_t, pair<FeatureBasePtr, FeatureBasePtr> > TrackMatches; // mat * * these fields of FeatureBase are initialized each time a feature is added to the track matrix: * - * add(Cap, track_id, f) will set f.capture_ptr = C and f.traci_id = traci_id. + * add(Cap, track_id, f) will set f.capture_ptr = C and f.track_id = track_id. * * so e.g. given a feature f, * * getTrack (f->trackId()) ; // returns all the track where feature f is. - * getSnapshot(f->getCapture()) ; // returns all the features in the same capture of f. + * getSnapshot(f->getCapture()) ; // returns all the features in the same capture of f. * */ @@ -83,8 +83,8 @@ class TrackMatrix void remove (FeatureBasePtr _ftr); void remove (size_t _track_id); void remove (CaptureBasePtr _cap); - SizeStd numTracks (); - SizeStd trackSize (size_t _track_id); + SizeStd numTracks (); + SizeStd trackSize (size_t _track_id); Track track (size_t _track_id); Snapshot snapshot (CaptureBasePtr _capture); vector<FeatureBasePtr> @@ -105,7 +105,8 @@ class TrackMatrix map<size_t, Track > tracks_; // map indexed by track_Id of ( maps indexed by TimeStamp of ( features ) ) // Across track: maps of Feature pointers indexed by track_Id. - map<size_t, Snapshot > snapshots_; // map indexed by capture_Id of ( maps indexed by track_Id of ( features ) ) +// map<size_t, Snapshot > snapshots_; // map indexed by capture_Id of ( maps indexed by track_Id of ( features ) ) + map<CaptureBasePtr, Snapshot > snapshots_; // map indexed by capture_ptr of ( maps indexed by track_Id of ( features ) ) }; } /* namespace wolf */ diff --git a/src/processor/track_matrix.cpp b/src/processor/track_matrix.cpp index af0bff7f350f7a317548de3b9048fad4874a8bfd..8ab0c78822a4cd5dc2462b4a413e0a9e95a222af 100644 --- a/src/processor/track_matrix.cpp +++ b/src/processor/track_matrix.cpp @@ -32,8 +32,8 @@ Track TrackMatrix::track(size_t _track_id) Snapshot TrackMatrix::snapshot(CaptureBasePtr _capture) { - if (_capture && snapshots_.count(_capture->id()) > 0) - return snapshots_.at(_capture->id()); + if (_capture && snapshots_.count(_capture) > 0) + return snapshots_.at(_capture); else return Snapshot(); } @@ -52,7 +52,7 @@ void TrackMatrix::add(size_t _track_id, CaptureBasePtr _cap, FeatureBasePtr _ftr if (_cap != _ftr->getCapture()) _ftr->setCapture(_cap); tracks_[_track_id].emplace(_cap->getTimeStamp(), _ftr); - snapshots_[_cap->id()].emplace(_track_id, _ftr); // will create new snapshot if _cap_id is not present + snapshots_[_cap].emplace(_track_id, _ftr); // will create new snapshot if _cap_id is not present } void TrackMatrix::remove(size_t _track_id) @@ -62,10 +62,18 @@ void TrackMatrix::remove(size_t _track_id) { for (auto const& pair_time_ftr : tracks_.at(_track_id)) { - SizeStd cap_id = pair_time_ftr.second->getCapture()->id(); - snapshots_.at(cap_id).erase(_track_id); - if (snapshots_.at(cap_id).empty()) - snapshots_.erase(cap_id); +// SizeStd cap_id = pair_time_ftr.second->getCapture()->id(); +// snapshots_.at(cap_id).erase(_track_id); +// if (snapshots_.at(cap_id).empty()) +// snapshots_.erase(cap_id); + + + + CaptureBasePtr cap = pair_time_ftr.second->getCapture(); + snapshots_.at(cap).erase(_track_id); + if (snapshots_.at(cap).empty()) + snapshots_.erase(cap); + } // Remove track @@ -76,10 +84,10 @@ void TrackMatrix::remove(size_t _track_id) void TrackMatrix::remove(CaptureBasePtr _cap) { // remove snapshot features from all tracks - if (snapshots_.count(_cap->id())) + if (snapshots_.count(_cap)) { TimeStamp ts = _cap->getTimeStamp(); - for (auto const& pair_trkid_ftr : snapshots_.at(_cap->id())) + for (auto const& pair_trkid_ftr : snapshots_.at(_cap)) { SizeStd trk_id = pair_trkid_ftr.first; tracks_.at(trk_id).erase(ts); @@ -88,7 +96,7 @@ void TrackMatrix::remove(CaptureBasePtr _cap) } // remove snapshot - snapshots_.erase(_cap->id()); + snapshots_.erase(_cap); } } @@ -103,9 +111,9 @@ void TrackMatrix::remove(FeatureBasePtr _ftr) if (tracks_.at(_ftr->trackId()).empty()) tracks_.erase(_ftr->trackId()); - snapshots_.at(cap->id()) .erase(_ftr->trackId()); - if (snapshots_.at(cap->id()).empty()) - snapshots_.erase(cap->id()); + snapshots_.at(cap) .erase(_ftr->trackId()); + if (snapshots_.at(cap).empty()) + snapshots_.erase(cap); } } } @@ -151,8 +159,8 @@ vector<FeatureBasePtr> TrackMatrix::trackAsVector(size_t _track_id) std::list<FeatureBasePtr> TrackMatrix::snapshotAsList(CaptureBasePtr _cap) { std::list<FeatureBasePtr> lst; - if (snapshots_.count(_cap->id())) - for (auto const& pair_trkid_ftr : snapshots_.at(_cap->id())) + if (snapshots_.count(_cap)) + for (auto const& pair_trkid_ftr : snapshots_.at(_cap)) lst.push_back(pair_trkid_ftr.second); return lst; }