17 std::vector<std::pair<float, BoundingBox*>> scored;
18 scored.reserve(bboxes.size());
20 for (
auto& bbox : bboxes) {
21 float max_class_score = 0.0F;
22 std::size_t max_class_idx = 0;
23 for (
const auto& entry : bbox.classification) {
24 if (entry.score > max_class_score) {
25 max_class_score = entry.score;
26 max_class_idx = entry.class_idx;
34 scored.emplace_back(score, &bbox);
37 std::sort(scored.begin(), scored.end(), [](
const auto& a,
const auto& b) { return a.first > b.first; });
39 std::vector<BoundingBox> kept;
40 kept.reserve(bboxes.size());
42 for (
const auto& candidate : scored) {
47 for (
const auto& kept_box : kept) {
48 if (candidate.second->overlaps(kept_box, config.
iou_threshold)) {
54 kept.push_back(*candidate.second);
61 bboxes = std::move(kept);