aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/BoundingBoxTransform.cpp
diff options
context:
space:
mode:
authorgiuros01 <giuseppe.rossini@arm.com>2018-11-16 10:39:59 +0000
committerGiuseppe Rossini <giuseppe.rossini@arm.com>2018-11-16 17:57:46 +0000
commitd696cb6d18c2fe66f1abce88bbd14faf2137ef89 (patch)
tree9428fea2613651e2d7ffb53b15c62c80594eb8e3 /tests/validation/reference/BoundingBoxTransform.cpp
parentc8df89f477c3dc63f396ad37bee8ed5d50dee4ac (diff)
downloadComputeLibrary-d696cb6d18c2fe66f1abce88bbd14faf2137ef89.tar.gz
COMPMID-1451: Fixes for BoundingBoxTransform
- Fixing a bug for which we did not scale the boxes before transforming them - Adding the correct_transform_coords option to BoundingBoxTransformInfo Change-Id: I40281254bcf87e7c8583c119e99562414fe59822
Diffstat (limited to 'tests/validation/reference/BoundingBoxTransform.cpp')
-rw-r--r--tests/validation/reference/BoundingBoxTransform.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/validation/reference/BoundingBoxTransform.cpp b/tests/validation/reference/BoundingBoxTransform.cpp
index 9918ff68c5..55dd165b51 100644
--- a/tests/validation/reference/BoundingBoxTransform.cpp
+++ b/tests/validation/reference/BoundingBoxTransform.cpp
@@ -50,7 +50,10 @@ SimpleTensor<T> bounding_box_transform(const SimpleTensor<T> &boxes, const Simpl
const int img_h = floor(info.img_height() / info.scale() + 0.5f);
const int img_w = floor(info.img_width() / info.scale() + 0.5f);
- const T scale = (info.apply_scale() ? T(info.scale()) : T(1));
+ const auto scale_after = (info.apply_scale() ? T(info.scale()) : T(1));
+ const auto scale_before = T(info.scale());
+ ARM_COMPUTE_ERROR_ON(scale_before <= 0);
+ const auto offset = (info.correct_transform_coords() ? T(1.f) : T(0.f));
const size_t box_fields = 4;
const size_t class_fields = 4;
@@ -59,10 +62,10 @@ SimpleTensor<T> bounding_box_transform(const SimpleTensor<T> &boxes, const Simpl
{
// Extract ROI information
const size_t start_box = box_fields * i;
- const T width = boxes[start_box + 2] - boxes[start_box] + T(1.0);
- const T height = boxes[start_box + 3] - boxes[start_box + 1] + T(1.0);
- const T ctr_x = boxes[start_box] + T(0.5) * width;
- const T ctr_y = boxes[start_box + 1] + T(0.5) * height;
+ const T width = (boxes[start_box + 2] / scale_before) - (boxes[start_box] / scale_before) + T(1.f);
+ const T height = (boxes[start_box + 3] / scale_before) - (boxes[start_box + 1] / scale_before) + T(1.f);
+ const T ctr_x = (boxes[start_box] / scale_before) + T(0.5f) * width;
+ const T ctr_y = (boxes[start_box + 1] / scale_before) + T(0.5f) * height;
for(size_t j = 0; j < num_classes; ++j)
{
@@ -84,10 +87,10 @@ SimpleTensor<T> bounding_box_transform(const SimpleTensor<T> &boxes, const Simpl
const T pred_h = T(std::exp(dh)) * height;
// Store the prediction into the output tensor
- pred_boxes_ptr[start_delta] = scale * utility::clamp<T>(pred_ctr_x - T(0.5) * pred_w, T(0), T(img_w - 1));
- pred_boxes_ptr[start_delta + 1] = scale * utility::clamp<T>(pred_ctr_y - T(0.5) * pred_h, T(0), T(img_h - 1));
- pred_boxes_ptr[start_delta + 2] = scale * utility::clamp<T>(pred_ctr_x + T(0.5) * pred_w, T(0), T(img_w - 1));
- pred_boxes_ptr[start_delta + 3] = scale * utility::clamp<T>(pred_ctr_y + T(0.5) * pred_h, T(0), T(img_h - 1));
+ pred_boxes_ptr[start_delta] = scale_after * utility::clamp<T>(pred_ctr_x - T(0.5f) * pred_w, T(0), T(img_w - 1));
+ pred_boxes_ptr[start_delta + 1] = scale_after * utility::clamp<T>(pred_ctr_y - T(0.5f) * pred_h, T(0), T(img_h - 1));
+ pred_boxes_ptr[start_delta + 2] = scale_after * utility::clamp<T>(pred_ctr_x + T(0.5f) * pred_w - offset, T(0), T(img_w - 1));
+ pred_boxes_ptr[start_delta + 3] = scale_after * utility::clamp<T>(pred_ctr_y + T(0.5f) * pred_h - offset, T(0), T(img_h - 1));
}
}
return pred_boxes;