diff options
Diffstat (limited to 'tests/validation/CPP')
-rw-r--r-- | tests/validation/CPP/HarrisCornerDetector.cpp | 2 | ||||
-rw-r--r-- | tests/validation/CPP/Sobel.cpp | 32 | ||||
-rw-r--r-- | tests/validation/CPP/Sobel.h | 3 |
3 files changed, 27 insertions, 10 deletions
diff --git a/tests/validation/CPP/HarrisCornerDetector.cpp b/tests/validation/CPP/HarrisCornerDetector.cpp index 3babfeed42..6cfcd8ecc5 100644 --- a/tests/validation/CPP/HarrisCornerDetector.cpp +++ b/tests/validation/CPP/HarrisCornerDetector.cpp @@ -45,7 +45,7 @@ std::tuple<SimpleTensor<T>, SimpleTensor<T>, float> compute_sobel(const SimpleTe SimpleTensor<T> grad_y; float norm_factor = 0.f; - std::tie(grad_x, grad_y) = sobel<T>(src, gradient_size, border_mode, constant_border_value); + std::tie(grad_x, grad_y) = sobel<T>(src, gradient_size, border_mode, constant_border_value, GradientDimension::GRAD_XY); switch(gradient_size) { diff --git a/tests/validation/CPP/Sobel.cpp b/tests/validation/CPP/Sobel.cpp index 314fbd4f8a..ff0e11d3a8 100644 --- a/tests/validation/CPP/Sobel.cpp +++ b/tests/validation/CPP/Sobel.cpp @@ -103,7 +103,7 @@ struct data_type<int> } // namespace template <typename T, typename U> -std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value) +std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension) { SimpleTensor<T> dst_x(src.shape(), data_type<T>::value, src.num_channels()); SimpleTensor<T> dst_y(src.shape(), data_type<T>::value, src.num_channels()); @@ -118,18 +118,34 @@ std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, in { continue; } - - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, - constant_border_value); - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, - constant_border_value); + switch(gradient_dimension) + { + case GradientDimension::GRAD_X: + apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, + constant_border_value); + break; + case GradientDimension::GRAD_Y: + apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, + constant_border_value); + break; + case GradientDimension::GRAD_XY: + apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, + constant_border_value); + apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, + constant_border_value); + break; + default: + ARM_COMPUTE_ERROR("Gradient dimension not supported"); + } } return std::make_pair(dst_x, dst_y); } -template std::pair<SimpleTensor<int16_t>, SimpleTensor<int16_t>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value); -template std::pair<SimpleTensor<int>, SimpleTensor<int>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value); +template std::pair<SimpleTensor<int16_t>, SimpleTensor<int16_t>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, + GradientDimension gradient_dimension); +template std::pair<SimpleTensor<int>, SimpleTensor<int>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, + GradientDimension gradient_dimension); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/Sobel.h b/tests/validation/CPP/Sobel.h index ab046639dc..9099f1a932 100644 --- a/tests/validation/CPP/Sobel.h +++ b/tests/validation/CPP/Sobel.h @@ -26,6 +26,7 @@ #include "arm_compute/core/Types.h" #include "tests/SimpleTensor.h" +#include "tests/Types.h" namespace arm_compute { @@ -36,7 +37,7 @@ namespace validation namespace reference { template <typename T, typename U> -std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value = 0); +std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension); } // namespace reference } // namespace validation } // namespace test |