@@ -457,16 +457,21 @@ void MultiObjectTracker::sanitizeTracker(
457
457
constexpr float min_iou_for_unknown_object = 0.001 ;
458
458
constexpr double distance_threshold = 5.0 ;
459
459
460
- // Create sorted list with non-UNKNOWN objects first, then by measurement count
461
- std::vector<std::shared_ptr<Tracker>> sorted_list_tracker (list_tracker.begin (), list_tracker.end ());
462
- std::sort (sorted_list_tracker.begin (), sorted_list_tracker.end (),
463
- [](const std::shared_ptr<Tracker>& a, const std::shared_ptr<Tracker>& b) {
460
+ // Create sorted list with non-UNKNOWN objects first, then by measurement count
461
+ std::vector<std::shared_ptr<Tracker>> sorted_list_tracker (
462
+ list_tracker_.begin (), list_tracker_.end ());
463
+ std::sort (
464
+ sorted_list_tracker.begin (), sorted_list_tracker.end (),
465
+ [&time ](const std::shared_ptr<Tracker> & a, const std::shared_ptr<Tracker> & b) {
464
466
bool a_unknown = (a->getHighestProbLabel () == Label::UNKNOWN);
465
467
bool b_unknown = (b->getHighestProbLabel () == Label::UNKNOWN);
466
468
if (a_unknown != b_unknown) {
467
469
return b_unknown; // Put non-UNKNOWN objects first
468
470
}
469
- return a->getTotalMeasurementCount () > b->getTotalMeasurementCount (); // Then sort by measurement count
471
+ if (a->getTotalMeasurementCount () != b->getTotalMeasurementCount ()) {
472
+ return a->getTotalMeasurementCount () > b->getTotalMeasurementCount (); // Then sort by measurement count
473
+ }
474
+ return a->getElapsedTimeFromLastUpdate (time ) < b->getElapsedTimeFromLastUpdate (time ); // Finally sort by elapsed time (smaller first)
470
475
});
471
476
472
477
/* delete collision tracker */
0 commit comments