Commit 49e6abca authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

Add no filter case in filter_boxes_by_score() if score_threshold is zero

This avoids us performing N comparisons for the given batch if the score
threshold used is less than zero. This allows us to simply just std::transform
all boxes without needing to perform a bunch of needles compares and use
constructs a std::pair of box score, idx directly.
parent 7f705c1d
...@@ -232,15 +232,27 @@ struct nonmaxsuppression ...@@ -232,15 +232,27 @@ struct nonmaxsuppression
auto insert_to_boxes_heap = auto insert_to_boxes_heap =
make_function_output_iterator([&](const auto& x) { boxes_heap.push(x); }); make_function_output_iterator([&](const auto& x) { boxes_heap.push(x); });
int64_t box_idx = 0; int64_t box_idx = 0;
transform_if(
scores_start, if(score_threshold > 0.0)
scores_start + num_boxes, {
insert_to_boxes_heap, transform_if(
[&](auto sc) { scores_start,
box_idx++; scores_start + num_boxes,
return sc >= score_threshold; insert_to_boxes_heap,
}, [&](auto sc) {
[&](auto sc) { return std::make_pair(sc, box_idx - 1); }); box_idx++;
return sc >= score_threshold;
},
[&](auto sc) { return std::make_pair(sc, box_idx - 1); });
}
else
{ // score is irrelevant, just push into boxes_heap and make a score-index pair
std::transform(
scores_start, scores_start + num_boxes, insert_to_boxes_heap, [&](auto sc) {
box_idx++;
return std::make_pair(sc, box_idx - 1);
});
}
return boxes_heap; return boxes_heap;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment