Skip to content

Commit f8d4663

Browse files
committed
Update the condition of erasing and small refactor
1 parent 67560e4 commit f8d4663

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

perception/multi_object_tracker/src/multi_object_tracker_core.cpp

+13-15
Original file line numberDiff line numberDiff line change
@@ -419,35 +419,33 @@ void MultiObjectTracker::sanitizeTracker(
419419
const auto iou = object_recognition_utils::get2dIoU(object1, object2, min_union_iou_area);
420420
const auto & label1 = sorted_list_tracker[i]->getHighestProbLabel();
421421
const auto & label2 = sorted_list_tracker[j]->getHighestProbLabel();
422-
bool should_delete_tracker2 = false;
422+
bool delete_candidate_tracker = false;
423423

424424
// If at least one of them is UNKNOWN, delete the one with lower IOU. Because the UNKNOWN
425425
// objects are not reliable.
426426
if (label1 == Label::UNKNOWN || label2 == Label::UNKNOWN) {
427427
if (min_iou_for_unknown_object < iou) {
428428
if (label2 == Label::UNKNOWN) {
429-
/* erase only when prioritized one has a measurement or the other one doesn't */
430-
if (sorted_list_tracker[i]->getNoMeasurementCount() <= 0 or
431-
sorted_list_tracker[j]->getNoMeasurementCount() > 0) {
432-
should_delete_tracker2 = true;
433-
}
429+
delete_candidate_tracker = true;
434430
}
435431
}
436432
} else { // If neither is UNKNOWN, delete the one with lower IOU.
437433
if (min_iou < iou) {
438434
/* erase only when prioritized one has a measurement */
439-
if (sorted_list_tracker[i]->getNoMeasurementCount() <= 0) {
440-
should_delete_tracker2 = true;
441-
}
435+
delete_candidate_tracker = true;
442436
}
443437
}
444438

445-
if (should_delete_tracker2) {
446-
// Remove from original list_tracker
447-
list_tracker.remove(sorted_list_tracker[j]);
448-
// Remove from sorted list
449-
sorted_list_tracker.erase(sorted_list_tracker.begin() + j);
450-
--j;
439+
if (delete_candidate_tracker) {
440+
/* erase only when prioritized one has a measurement or the other one doesn't */
441+
if (sorted_list_tracker[i]->getNoMeasurementCount() <= 0 or
442+
sorted_list_tracker[j]->getNoMeasurementCount() > 0) {
443+
// Remove from original list_tracker
444+
list_tracker.remove(sorted_list_tracker[j]);
445+
// Remove from sorted list
446+
sorted_list_tracker.erase(sorted_list_tracker.begin() + j);
447+
--j;
448+
}
451449
}
452450
}
453451
}

0 commit comments

Comments
 (0)