From 562fe0fcedace39735ead089cfdc4e2b07e40aad Mon Sep 17 00:00:00 2001 From: Abe Mbise Date: Fri, 9 Feb 2018 14:13:02 +0000 Subject: COMPMID-578: Faster common keypoint validation routine for FAST and Harris corners Change-Id: I1f3038ccfa6be5e0a19bec11a89af5ed2247c42f Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/119936 Reviewed-by: Anthony Barbier Reviewed-by: Georgios Pinitas Tested-by: Jenkins --- tests/validation/fixtures/FastCornersFixture.h | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/FastCornersFixture.h b/tests/validation/fixtures/FastCornersFixture.h index 0b827f74b5..6f2add6210 100644 --- a/tests/validation/fixtures/FastCornersFixture.h +++ b/tests/validation/fixtures/FastCornersFixture.h @@ -49,7 +49,7 @@ class FastCornersValidationFixture : public framework::Fixture { public: template - void setup(TensorShape shape, Format format, bool suppress_nonmax, BorderMode border_mode) + void setup(std::string image, Format format, bool suppress_nonmax, BorderMode border_mode) { std::mt19937 gen(library->seed()); std::uniform_int_distribution int_dist(0, 255); @@ -58,15 +58,15 @@ public: const uint8_t constant_border_value = int_dist(gen); const float threshold = real_dist(gen); - _target = compute_target(shape, format, threshold, suppress_nonmax, border_mode, constant_border_value); - _reference = compute_reference(shape, format, threshold, suppress_nonmax, border_mode, constant_border_value); + _target = compute_target(image, format, threshold, suppress_nonmax, border_mode, constant_border_value); + _reference = compute_reference(image, format, threshold, suppress_nonmax, border_mode, constant_border_value); } protected: template - void fill(U &&tensor) + void fill(U &&tensor, RawTensor raw) { - library->fill_tensor_uniform(tensor, 0); + library->fill(tensor, raw); } template ::value, int>::type = 0> @@ -79,19 +79,20 @@ protected: void configure_target(F &func, TensorType &src, ArrayType &corners, unsigned int *num_corners, float threshold, bool suppress_nonmax, BorderMode border_mode, uint8_t constant_border_value) { ARM_COMPUTE_UNUSED(num_corners); - // ARM_COMPUTE_ERROR_ON(num_corners); func.configure(&src, threshold, suppress_nonmax, &corners, border_mode, constant_border_value); } - ArrayType compute_target(const TensorShape &shape, Format format, float threshold, bool suppress_nonmax, BorderMode border_mode, uint8_t constant_border_value) + ArrayType compute_target(const std::string &image, Format format, float threshold, bool suppress_nonmax, BorderMode border_mode, uint8_t constant_border_value) { + // Load the image (cached by the library if loaded before) + const RawTensor &raw = library->get(image, format); + // Create tensors - TensorType src = create_tensor(shape, data_type_from_format(format)); - src.info()->set_format(format); + TensorType src = create_tensor(raw.shape(), format); // Create array of keypoints - ArrayType corners(shape.total_size()); - unsigned int num_corners = shape.total_size(); + ArrayType corners(raw.shape().total_size()); + unsigned int num_corners = raw.shape().total_size(); // Create and configure function FunctionType fast_corners; @@ -105,7 +106,7 @@ protected: ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); // Fill tensors - fill(AccessorType(src)); + fill(AccessorType(src), raw); // Compute function fast_corners.run(); @@ -113,13 +114,16 @@ protected: return corners; } - std::vector compute_reference(const TensorShape &shape, Format format, float threshold, bool suppress_nonmax, BorderMode border_mode, uint8_t constant_border_value) + std::vector compute_reference(const std::string &image, Format format, float threshold, bool suppress_nonmax, BorderMode border_mode, uint8_t constant_border_value) { + // Load the image (cached by the library if loaded before) + const RawTensor &raw = library->get(image, format); + // Create reference - SimpleTensor src{ shape, format }; + SimpleTensor src{ raw.shape(), format }; // Fill reference - fill(src); + fill(src, raw); // Compute reference return reference::fast_corners(src, threshold, suppress_nonmax, border_mode, constant_border_value); -- cgit v1.2.1