Commit 450d164a authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

Move sort and area calculations to batch_box() creation

Offload these calculations when the batch box is created since we're now
copying by value, no need to recalculate these parameters.

Reduces the work repeated for the top_box selected but still leverages parallelism
for each subsequent box compared as our lambda in copy_if calls batch_box()
prior to suppress_by_iou
parent 347e79c1
...@@ -141,6 +141,7 @@ struct nonmaxsuppression ...@@ -141,6 +141,7 @@ struct nonmaxsuppression
{ {
std::array<double, 2> x; std::array<double, 2> x;
std::array<double, 2> y; std::array<double, 2> y;
double stored_area;
void sort() void sort()
{ {
...@@ -184,16 +185,16 @@ struct nonmaxsuppression ...@@ -184,16 +185,16 @@ struct nonmaxsuppression
result.y = {static_cast<double>(start[0]), static_cast<double>(start[2])}; result.y = {static_cast<double>(start[0]), static_cast<double>(start[2])};
} }
result.sort();
result.stored_area = result.area();
return result; return result;
} }
inline bool suppress_by_iou(box b1, box b2, double iou_threshold) const inline bool suppress_by_iou(box b1, box b2, double iou_threshold) const
{ {
b1.sort(); const double area1 = b1.stored_area;
b2.sort(); const double area2 = b2.stored_area;
const double area1 = b1.area();
const double area2 = b2.area();
if(area1 <= .0f or area2 <= .0f) if(area1 <= .0f or area2 <= .0f)
{ {
......
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