aboutsummaryrefslogtreecommitdiff
path: root/tests/Utils.h
diff options
context:
space:
mode:
authorJohn Richardson <john.richardson@arm.com>2018-02-22 14:09:31 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:49:16 +0000
commit8de92619e223225aabdca873c02f231d8e941fd1 (patch)
tree6b0c7a04e58e120fc9969270cb7ba432a31e1258 /tests/Utils.h
parent2abb216e1aaeefe65c8a7e6294b4735f0647c927 (diff)
downloadComputeLibrary-8de92619e223225aabdca873c02f231d8e941fd1.tar.gz
COMPMID-585: Port OpticalFlow to new validation
Change-Id: Ia36bd11ca27420d3059eea15df81b237900149ec Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/125175 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: John Richardson <john.richardson@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/Utils.h')
-rw-r--r--tests/Utils.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/Utils.h b/tests/Utils.h
index 4feed4e491..7d960dd08f 100644
--- a/tests/Utils.h
+++ b/tests/Utils.h
@@ -28,6 +28,7 @@
#include "arm_compute/core/Error.h"
#include "arm_compute/core/FixedPoint.h"
#include "arm_compute/core/HOGInfo.h"
+#include "arm_compute/core/PyramidInfo.h"
#include "arm_compute/core/Size2D.h"
#include "arm_compute/core/TensorInfo.h"
#include "arm_compute/core/TensorShape.h"
@@ -548,6 +549,21 @@ inline T create_HOG(const HOGInfo &hog_info)
return hog;
}
+/** Create and initialize a Pyramid of the given type.
+ *
+ * @param[in] pyramid_info The PyramidInfo object.
+ *
+ * @return Initialized Pyramid of given type.
+ */
+template <typename T>
+inline T create_pyramid(const PyramidInfo &pyramid_info)
+{
+ T pyramid;
+ pyramid.init_auto_padding(pyramid_info);
+
+ return pyramid;
+}
+
/** Create a vector of random ROIs.
*
* @param[in] shape The shape of the input tensor.
@@ -618,6 +634,44 @@ inline std::vector<T> generate_random_real(unsigned int num_values, T min, T max
return v;
}
+/** Create a vector of random keypoints for pyramid representation.
+ *
+ * @param[in] shape The shape of the input tensor.
+ * @param[in] num_keypoints The number of keypoints to be created.
+ * @param[in] seed The random seed to be used.
+ * @param[in] num_levels The number of pyramid levels.
+ *
+ * @return A vector that contains the requested number of random keypoints
+ */
+inline std::vector<KeyPoint> generate_random_keypoints(const TensorShape &shape, size_t num_keypoints, std::random_device::result_type seed, size_t num_levels = 1)
+{
+ std::vector<KeyPoint> keypoints;
+ std::mt19937 gen(seed);
+
+ // Calculate distribution bounds
+ const auto min = static_cast<int>(std::pow(2, num_levels));
+ const auto max_width = static_cast<int>(shape.x());
+ const auto max_height = static_cast<int>(shape.y());
+
+ ARM_COMPUTE_ERROR_ON(min > max_width || min > max_height);
+
+ // Create distributions
+ std::uniform_int_distribution<> dist_w(min, max_width);
+ std::uniform_int_distribution<> dist_h(min, max_height);
+
+ for(unsigned int i = 0; i < num_keypoints; i++)
+ {
+ KeyPoint keypoint;
+ keypoint.x = dist_w(gen);
+ keypoint.y = dist_h(gen);
+ keypoint.tracking_status = 1;
+
+ keypoints.push_back(keypoint);
+ }
+
+ return keypoints;
+}
+
template <typename T, typename ArrayAccessor_T>
inline void fill_array(ArrayAccessor_T &&array, const std::vector<T> &v)
{