From c6f9510bcb754afaadfe9477ff85d6c55ffcf43b Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 30 Mar 2021 10:03:01 +0100 Subject: Remove Computer Vision generic interfaces and types Removes: - reference validation routines - CV related types and structures - CV related interfaces Signed-off-by: Georgios Pinitas Change-Id: I3a203da12d9b04c154059b190aeba18a611149a9 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5340 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/core/NEON/NEKernels.h | 3 - .../kernels/NECumulativeDistributionKernel.cpp | 114 ----- .../NEON/kernels/NECumulativeDistributionKernel.h | 85 ---- src/core/NEON/kernels/NEFillArrayKernel.cpp | 92 ---- src/core/NEON/kernels/NEFillArrayKernel.h | 77 --- src/core/NEON/kernels/NELKTrackerKernel.cpp | 540 --------------------- src/core/NEON/kernels/NELKTrackerKernel.h | 141 ------ src/core/NEON/kernels/NEROIPoolingLayerKernel.h | 5 +- 8 files changed, 1 insertion(+), 1056 deletions(-) delete mode 100644 src/core/NEON/kernels/NECumulativeDistributionKernel.cpp delete mode 100644 src/core/NEON/kernels/NECumulativeDistributionKernel.h delete mode 100644 src/core/NEON/kernels/NEFillArrayKernel.cpp delete mode 100644 src/core/NEON/kernels/NEFillArrayKernel.h delete mode 100644 src/core/NEON/kernels/NELKTrackerKernel.cpp delete mode 100644 src/core/NEON/kernels/NELKTrackerKernel.h (limited to 'src/core/NEON') diff --git a/src/core/NEON/NEKernels.h b/src/core/NEON/NEKernels.h index 0acaebb582..59884e2d05 100644 --- a/src/core/NEON/NEKernels.h +++ b/src/core/NEON/NEKernels.h @@ -36,7 +36,6 @@ #include "src/core/NEON/kernels/NEConvertFullyConnectedWeightsKernel.h" #include "src/core/NEON/kernels/NEConvertQuantizedSignednessKernel.h" #include "src/core/NEON/kernels/NECropKernel.h" -#include "src/core/NEON/kernels/NECumulativeDistributionKernel.h" #include "src/core/NEON/kernels/NEDepthConvertLayerKernel.h" #include "src/core/NEON/kernels/NEDepthToSpaceLayerKernel.h" #include "src/core/NEON/kernels/NEDepthwiseConvolutionLayerNativeKernel.h" @@ -45,7 +44,6 @@ #include "src/core/NEON/kernels/NEFFTDigitReverseKernel.h" #include "src/core/NEON/kernels/NEFFTRadixStageKernel.h" #include "src/core/NEON/kernels/NEFFTScaleKernel.h" -#include "src/core/NEON/kernels/NEFillArrayKernel.h" #include "src/core/NEON/kernels/NEFillBorderKernel.h" #include "src/core/NEON/kernels/NEFuseBatchNormalizationKernel.h" #include "src/core/NEON/kernels/NEGEMMInterleave4x4Kernel.h" @@ -65,7 +63,6 @@ #include "src/core/NEON/kernels/NEIm2ColKernel.h" #include "src/core/NEON/kernels/NEInstanceNormalizationLayerKernel.h" #include "src/core/NEON/kernels/NEL2NormalizeLayerKernel.h" -#include "src/core/NEON/kernels/NELKTrackerKernel.h" #include "src/core/NEON/kernels/NELogicalKernel.h" #include "src/core/NEON/kernels/NEMaxUnpoolingLayerKernel.h" #include "src/core/NEON/kernels/NEMeanStdDevNormalizationKernel.h" diff --git a/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp b/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp deleted file mode 100644 index 58a9a2f1fb..0000000000 --- a/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/NEON/kernels/NECumulativeDistributionKernel.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/IDistribution1D.h" -#include "arm_compute/core/ILut.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Validate.h" -#include "src/core/helpers/AutoConfiguration.h" -#include "src/core/helpers/WindowHelpers.h" - -#include -#include -#include - -using namespace arm_compute; - -NECumulativeDistributionKernel::NECumulativeDistributionKernel() - : _input(nullptr), _distribution(nullptr), _cumulative_sum(nullptr), _output(nullptr) -{ -} - -bool NECumulativeDistributionKernel::is_parallelisable() const -{ - return false; -} - -void NECumulativeDistributionKernel::configure(const IImage *input, const IDistribution1D *distribution, IDistribution1D *cumulative_sum, ILut *output) -{ - ARM_COMPUTE_ERROR_ON_NULLPTR(input, distribution, cumulative_sum, output); - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - - set_format_if_unknown(*input->info(), Format::U8); - - ARM_COMPUTE_ERROR_ON(distribution->num_bins() != cumulative_sum->num_bins()); - ARM_COMPUTE_ERROR_ON(distribution->num_bins() != output->num_elements()); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(input->info()->data_type() != output->type()); - - _input = input; - _distribution = distribution; - _cumulative_sum = cumulative_sum; - _output = output; - - INEKernel::configure(calculate_max_window(*input->info())); -} - -void NECumulativeDistributionKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_UNUSED(window); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - ARM_COMPUTE_ERROR_ON(_distribution->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_cumulative_sum->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_output->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON_MSG(_distribution->num_bins() < 256, "Distribution must have 256 bins"); - - // Calculate the cumulative distribution (summed histogram). - const uint32_t *hist = _distribution->buffer(); - uint32_t *cumulative_sum = _cumulative_sum->buffer(); - uint8_t *output = _output->buffer(); - - // Calculate cumulative distribution - std::partial_sum(hist, hist + _histogram_size, cumulative_sum); - - // Get the number of pixels that have the lowest value in the input image - const uint32_t cd_min = *std::find_if(hist, hist + _histogram_size, [](const uint32_t &v) - { - return v > 0; - }); - const uint32_t image_size = cumulative_sum[_histogram_size - 1]; - - ARM_COMPUTE_ERROR_ON(cd_min > image_size); - - // Create mapping lookup table - if(image_size == cd_min) - { - std::iota(output, output + _histogram_size, 0); - } - else - { - const float diff = image_size - cd_min; - - for(unsigned int x = 0; x < _histogram_size; ++x) - { - output[x] = lround((cumulative_sum[x] - cd_min) / diff * 255.0f); - } - } -} diff --git a/src/core/NEON/kernels/NECumulativeDistributionKernel.h b/src/core/NEON/kernels/NECumulativeDistributionKernel.h deleted file mode 100644 index 1f8c65b5fa..0000000000 --- a/src/core/NEON/kernels/NECumulativeDistributionKernel.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_NECUMULATIVEDISTRIBUTIONKERNEL_H -#define ARM_COMPUTE_NECUMULATIVEDISTRIBUTIONKERNEL_H - -#include "src/core/NEON/INEKernel.h" - -#include - -namespace arm_compute -{ -class IDistribution1D; -class ILut; -class ITensor; -using IImage = ITensor; - -/** Interface for the cumulative distribution (cummulative summmation) calculation kernel. - * - * This kernel calculates the cumulative sum of a given distribution (meaning that each output element - * is the sum of all its previous elements including itself) and creates a lookup table with the normalized - * pixel intensities which is used for improve the constrast of the image. - */ -class NECumulativeDistributionKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NECumulativeDistributionKernel"; - } - /** Default constructor */ - NECumulativeDistributionKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NECumulativeDistributionKernel(const NECumulativeDistributionKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NECumulativeDistributionKernel &operator=(const NECumulativeDistributionKernel &) = delete; - /** Allow instances of this class to be moved */ - NECumulativeDistributionKernel(NECumulativeDistributionKernel &&) = default; - /** Allow instances of this class to be moved */ - NECumulativeDistributionKernel &operator=(NECumulativeDistributionKernel &&) = default; - /** Default destructor */ - ~NECumulativeDistributionKernel() = default; - /** Set the input and output distribution. - * - * @param[in] input Input image. Data type supported: U8 - * @param[in] distribution Unnormalized 256-bin distribution of the input image. - * @param[out] cumulative_sum Cummulative distribution (Summed histogram). Should be same size as @p distribution. - * @param[out] output Equalization lookup table. Should consist of 256 entries of U8 elements. - */ - void configure(const IImage *input, const IDistribution1D *distribution, IDistribution1D *cumulative_sum, ILut *output); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - bool is_parallelisable() const override; - -private: - const IImage *_input; /**< Input image. */ - const IDistribution1D *_distribution; /**< Input histogram of the input image. */ - IDistribution1D *_cumulative_sum; /**< The cummulative distribution. */ - ILut *_output; /**< Output with the equalization lookup table. */ -private: - static const uint32_t _histogram_size = 256; /**< Default histogram size of 256. */ -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_NECUMULATIVEDISTRIBUTIONKERNEL_H */ diff --git a/src/core/NEON/kernels/NEFillArrayKernel.cpp b/src/core/NEON/kernels/NEFillArrayKernel.cpp deleted file mode 100644 index e8ae926fbf..0000000000 --- a/src/core/NEON/kernels/NEFillArrayKernel.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/NEON/kernels/NEFillArrayKernel.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/IAccessWindow.h" -#include "arm_compute/core/Validate.h" -#include "src/core/helpers/WindowHelpers.h" - -using namespace arm_compute; - -NEFillArrayKernel::NEFillArrayKernel() - : _input(nullptr), _output(nullptr), _threshold(0) -{ -} - -void NEFillArrayKernel::configure(const IImage *input, uint8_t threshold, IKeyPointArray *output) -{ - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(nullptr == output); - - _input = input; - _output = output; - _threshold = threshold; - - constexpr unsigned int num_elems_processed_per_iteration = 1; - - // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration)); - INEKernel::configure(win); -} - -bool NEFillArrayKernel::is_parallelisable() const -{ - return false; -} - -void NEFillArrayKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - - Iterator input(_input, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - const uint8_t value = *input.ptr(); - - if(value >= _threshold) - { - KeyPoint p; - p.x = id.x(); - p.y = id.y(); - p.strength = value; - p.tracking_status = 1; - p.scale = 0.f; - p.orientation = 0.f; - p.error = 0.f; - - if(!_output->push_back(p)) - { - return; //Overflowed: stop trying to add more points - } - } - }, - input); -} diff --git a/src/core/NEON/kernels/NEFillArrayKernel.h b/src/core/NEON/kernels/NEFillArrayKernel.h deleted file mode 100644 index c9841679d1..0000000000 --- a/src/core/NEON/kernels/NEFillArrayKernel.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_NEFILLARRAYKERNEL_H -#define ARM_COMPUTE_NEFILLARRAYKERNEL_H - -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/Types.h" -#include "src/core/NEON/INEKernel.h" - -#include - -namespace arm_compute -{ -class ITensor; -using IImage = ITensor; - -/** This kernel adds all texels greater than or equal to the threshold value to the keypoint array. */ -class NEFillArrayKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NEFillArrayKernel"; - } - /** Default contructor */ - NEFillArrayKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEFillArrayKernel(const NEFillArrayKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEFillArrayKernel &operator=(const NEFillArrayKernel &) = delete; - /** Allow instances of this class to be moved */ - NEFillArrayKernel(NEFillArrayKernel &&) = default; - /** Allow instances of this class to be moved */ - NEFillArrayKernel &operator=(NEFillArrayKernel &&) = default; - /** Default detructor */ - ~NEFillArrayKernel() = default; - - /** Initialise the kernel. - * - * @param[in] input Source image. Data type supported: U8. - * @param[in] threshold Texels greater than the threshold will be added to the array. - * @param[out] output Arrays of keypoints to store the results. - */ - void configure(const IImage *input, uint8_t threshold, IKeyPointArray *output); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - bool is_parallelisable() const override; - -private: - const IImage *_input; - IKeyPointArray *_output; - uint8_t _threshold; -}; -} // namespace arm_compute -#endif /* ARM_COMPUTE_NEFILLARRAYKERNEL_H*/ diff --git a/src/core/NEON/kernels/NELKTrackerKernel.cpp b/src/core/NEON/kernels/NELKTrackerKernel.cpp deleted file mode 100644 index 442f001102..0000000000 --- a/src/core/NEON/kernels/NELKTrackerKernel.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/NEON/kernels/NELKTrackerKernel.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/core/Window.h" -#include "src/core/AccessWindowStatic.h" -#include "src/core/helpers/AutoConfiguration.h" -#include "src/core/helpers/WindowHelpers.h" - -#include -#include - -using namespace arm_compute; - -/** Constants used for Lucas-Kanade Algorithm */ -constexpr int W_BITS = 14; -constexpr float D0 = 1 << W_BITS; -constexpr float DETERMINANT_THRESHOLD = 1.0e-07f; // Threshold for the determinant. Used for lost tracking criteria -constexpr float EIGENVALUE_THRESHOLD = 1.0e-04f; // Thresholds for minimum eigenvalue. Used for lost tracking criteria -constexpr float FLT_SCALE = 1.0f / (1 << 20); - -namespace -{ -enum class BilinearInterpolation -{ - BILINEAR_OLD_NEW, - BILINEAR_SCHARR -}; - -template -constexpr int INT_ROUND(T x, int n) -{ - return (x + (1 << (n - 1))) >> n; -} - -template -inline int get_pixel(const ITensor *tensor, int xi, int yi, int iw00, int iw01, int iw10, int iw11, int scale) -{ - const auto px00 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi, yi))); - const auto px01 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi + 1, yi))); - const auto px10 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi, yi + 1))); - const auto px11 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi + 1, yi + 1))); - - return INT_ROUND(px00 * iw00 + px01 * iw01 + px10 * iw10 + px11 * iw11, scale); -} - -inline int32x4_t compute_bilinear_interpolation(int16x8_t top_row, int16x8_t bottom_row, int16x4_t w00, int16x4_t w01, int16x4_t w10, int16x4_t w11, int32x4_t shift) -{ - // Get the left column of upper row - const int16x4_t px00 = vget_low_s16(top_row); - - // Get the right column of upper row - const int16x4_t px01 = vext_s16(px00, vget_high_s16(top_row), 1); - - // Get the left column of lower row - const int16x4_t px10 = vget_low_s16(bottom_row); - - // Get the right column of right row - const int16x4_t px11 = vext_s16(px10, vget_high_s16(bottom_row), 1); - - // Apply the bilinear filter - return vqrshlq_s32(vmull_s16(px00, w00) + vmull_s16(px01, w01) + vmull_s16(px10, w10) + vmull_s16(px11, w11), shift); -} -} // namespace - -void NELKTrackerKernel::init_keypoints(int start, int end) -{ - if(_level == _num_levels - 1) - { - const float level_scale = pow(_pyramid_scale, _level); - - for(int i = start; i < end; ++i) - { - _old_points_internal->at(i).x = _old_points->at(i).x * level_scale; - _old_points_internal->at(i).y = _old_points->at(i).y * level_scale; - _old_points_internal->at(i).tracking_status = true; - - NELKInternalKeypoint keypoint_to_track; - - if(_use_initial_estimate) - { - keypoint_to_track.x = _new_points_estimates->at(i).x * level_scale; - keypoint_to_track.y = _new_points_estimates->at(i).y * level_scale; - keypoint_to_track.tracking_status = (_new_points_estimates->at(i).tracking_status == 1); - } - else - { - keypoint_to_track.x = _old_points_internal->at(i).x; - keypoint_to_track.y = _old_points_internal->at(i).y; - keypoint_to_track.tracking_status = true; - } - - _new_points_internal->at(i) = keypoint_to_track; - } - } - else - { - for(int i = start; i < end; ++i) - { - _old_points_internal->at(i).x /= _pyramid_scale; - _old_points_internal->at(i).y /= _pyramid_scale; - _new_points_internal->at(i).x /= _pyramid_scale; - _new_points_internal->at(i).y /= _pyramid_scale; - } - } -} - -std::tuple NELKTrackerKernel::compute_spatial_gradient_matrix(const NELKInternalKeypoint &keypoint, int32_t *bilinear_ix, int32_t *bilinear_iy) -{ - int iA11 = 0; - int iA12 = 0; - int iA22 = 0; - - int32x4_t nA11 = vdupq_n_s32(0); - int32x4_t nA12 = vdupq_n_s32(0); - int32x4_t nA22 = vdupq_n_s32(0); - - float keypoint_int_x = 0; - float keypoint_int_y = 0; - - const float wx = std::modf(keypoint.x, &keypoint_int_x); - const float wy = std::modf(keypoint.y, &keypoint_int_y); - - const int iw00 = roundf((1.0f - wx) * (1.0f - wy) * D0); - const int iw01 = roundf(wx * (1.0f - wy) * D0); - const int iw10 = roundf((1.0f - wx) * wy * D0); - const int iw11 = D0 - iw00 - iw01 - iw10; - - const int16x4_t nw00 = vdup_n_s16(iw00); - const int16x4_t nw01 = vdup_n_s16(iw01); - const int16x4_t nw10 = vdup_n_s16(iw10); - const int16x4_t nw11 = vdup_n_s16(iw11); - - // Convert stride from uint_t* to int16_t* - const size_t row_stride = _old_scharr_gx->info()->strides_in_bytes()[1] / 2; - const Coordinates top_left_window_corner(static_cast(keypoint_int_x) - _window_dimension / 2, static_cast(keypoint_int_y) - _window_dimension / 2); - auto idx = reinterpret_cast(_old_scharr_gx->buffer() + _old_scharr_gx->info()->offset_element_in_bytes(top_left_window_corner)); - auto idy = reinterpret_cast(_old_scharr_gy->buffer() + _old_scharr_gy->info()->offset_element_in_bytes(top_left_window_corner)); - static const int32x4_t nshifter_scharr = vdupq_n_s32(-W_BITS); - - for(int ky = 0; ky < _window_dimension; ++ky, idx += row_stride, idy += row_stride) - { - int kx = 0; - - // Calculate elements in blocks of four as long as possible - for(; kx <= _window_dimension - 4; kx += 4) - { - // Interpolation X - const int16x8_t ndx_row1 = vld1q_s16(idx + kx); - const int16x8_t ndx_row2 = vld1q_s16(idx + kx + row_stride); - - const int32x4_t nxval = compute_bilinear_interpolation(ndx_row1, ndx_row2, nw00, nw01, nw10, nw11, nshifter_scharr); - - // Interpolation Y - const int16x8_t ndy_row1 = vld1q_s16(idy + kx); - const int16x8_t ndy_row2 = vld1q_s16(idy + kx + row_stride); - - const int32x4_t nyval = compute_bilinear_interpolation(ndy_row1, ndy_row2, nw00, nw01, nw10, nw11, nshifter_scharr); - - // Store the intermediate data so that we don't need to recalculate them in later stage - vst1q_s32(bilinear_ix + kx + ky * _window_dimension, nxval); - vst1q_s32(bilinear_iy + kx + ky * _window_dimension, nyval); - - // Accumulate Ix^2 - nA11 = vmlaq_s32(nA11, nxval, nxval); - // Accumulate Ix * Iy - nA12 = vmlaq_s32(nA12, nxval, nyval); - // Accumulate Iy^2 - nA22 = vmlaq_s32(nA22, nyval, nyval); - } - - // Calculate the leftover elements - for(; kx < _window_dimension; ++kx) - { - const int32_t ixval = get_pixel(_old_scharr_gx, top_left_window_corner.x() + kx, top_left_window_corner.y() + ky, - iw00, iw01, iw10, iw11, W_BITS); - const int32_t iyval = get_pixel(_old_scharr_gy, top_left_window_corner.x() + kx, top_left_window_corner.y() + ky, - iw00, iw01, iw10, iw11, W_BITS); - - iA11 += ixval * ixval; - iA12 += ixval * iyval; - iA22 += iyval * iyval; - - bilinear_ix[kx + ky * _window_dimension] = ixval; - bilinear_iy[kx + ky * _window_dimension] = iyval; - } - } - - iA11 += vgetq_lane_s32(nA11, 0) + vgetq_lane_s32(nA11, 1) + vgetq_lane_s32(nA11, 2) + vgetq_lane_s32(nA11, 3); - iA12 += vgetq_lane_s32(nA12, 0) + vgetq_lane_s32(nA12, 1) + vgetq_lane_s32(nA12, 2) + vgetq_lane_s32(nA12, 3); - iA22 += vgetq_lane_s32(nA22, 0) + vgetq_lane_s32(nA22, 1) + vgetq_lane_s32(nA22, 2) + vgetq_lane_s32(nA22, 3); - - return std::make_tuple(iA11, iA12, iA22); -} - -std::pair NELKTrackerKernel::compute_image_mismatch_vector(const NELKInternalKeypoint &old_keypoint, const NELKInternalKeypoint &new_keypoint, const int32_t *bilinear_ix, - const int32_t *bilinear_iy) -{ - int ib1 = 0; - int ib2 = 0; - - int32x4_t nb1 = vdupq_n_s32(0); - int32x4_t nb2 = vdupq_n_s32(0); - - // Compute weights for the old keypoint - float old_keypoint_int_x = 0; - float old_keypoint_int_y = 0; - - const float old_wx = std::modf(old_keypoint.x, &old_keypoint_int_x); - const float old_wy = std::modf(old_keypoint.y, &old_keypoint_int_y); - - const int iw00_old = roundf((1.0f - old_wx) * (1.0f - old_wy) * D0); - const int iw01_old = roundf(old_wx * (1.0f - old_wy) * D0); - const int iw10_old = roundf((1.0f - old_wx) * old_wy * D0); - const int iw11_old = D0 - iw00_old - iw01_old - iw10_old; - - const int16x4_t nw00_old = vdup_n_s16(iw00_old); - const int16x4_t nw01_old = vdup_n_s16(iw01_old); - const int16x4_t nw10_old = vdup_n_s16(iw10_old); - const int16x4_t nw11_old = vdup_n_s16(iw11_old); - - // Compute weights for the new keypoint - float new_keypoint_int_x = 0; - float new_keypoint_int_y = 0; - - const float new_wx = std::modf(new_keypoint.x, &new_keypoint_int_x); - const float new_wy = std::modf(new_keypoint.y, &new_keypoint_int_y); - - const int iw00_new = roundf((1.0f - new_wx) * (1.0f - new_wy) * D0); - const int iw01_new = roundf(new_wx * (1.0f - new_wy) * D0); - const int iw10_new = roundf((1.0f - new_wx) * new_wy * D0); - const int iw11_new = D0 - iw00_new - iw01_new - iw10_new; - - const int16x4_t nw00_new = vdup_n_s16(iw00_new); - const int16x4_t nw01_new = vdup_n_s16(iw01_new); - const int16x4_t nw10_new = vdup_n_s16(iw10_new); - const int16x4_t nw11_new = vdup_n_s16(iw11_new); - - const int row_stride = _input_new->info()->strides_in_bytes()[1]; - const Coordinates top_left_window_corner_old(static_cast(old_keypoint_int_x) - _window_dimension / 2, static_cast(old_keypoint_int_y) - _window_dimension / 2); - const Coordinates top_left_window_corner_new(static_cast(new_keypoint_int_x) - _window_dimension / 2, static_cast(new_keypoint_int_y) - _window_dimension / 2); - const uint8_t *old_ptr = _input_old->buffer() + _input_old->info()->offset_element_in_bytes(top_left_window_corner_old); - const uint8_t *new_ptr = _input_new->buffer() + _input_new->info()->offset_element_in_bytes(top_left_window_corner_new); - static const int32x4_t nshifter_tensor = vdupq_n_s32(-(W_BITS - 5)); - - for(int ky = 0; ky < _window_dimension; ++ky, new_ptr += row_stride, old_ptr += row_stride) - { - int kx = 0; - - // Calculate elements in blocks of four as long as possible - for(; kx <= _window_dimension - 4; kx += 4) - { - // Interpolation old tensor - const int16x8_t nold_row1 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(old_ptr + kx))); - const int16x8_t nold_row2 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(old_ptr + kx + row_stride))); - - const int32x4_t noldval = compute_bilinear_interpolation(nold_row1, nold_row2, nw00_old, nw01_old, nw10_old, nw11_old, nshifter_tensor); - - // Interpolation new tensor - const int16x8_t nnew_row1 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(new_ptr + kx))); - const int16x8_t nnew_row2 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(new_ptr + kx + row_stride))); - - const int32x4_t nnewval = compute_bilinear_interpolation(nnew_row1, nnew_row2, nw00_new, nw01_new, nw10_new, nw11_new, nshifter_tensor); - - // Calculate It gradient, i.e. pixelwise difference between old and new tensor - const int32x4_t diff = vsubq_s32(nnewval, noldval); - - // Load the Ix and Iy gradient computed in the previous stage - const int32x4_t nxval = vld1q_s32(bilinear_ix + kx + ky * _window_dimension); - const int32x4_t nyval = vld1q_s32(bilinear_iy + kx + ky * _window_dimension); - - // Caculate Ix * It and Iy * It, and accumulate the results - nb1 = vmlaq_s32(nb1, diff, nxval); - nb2 = vmlaq_s32(nb2, diff, nyval); - } - - // Calculate the leftover elements - for(; kx < _window_dimension; ++kx) - { - const int32_t ival = get_pixel(_input_old, top_left_window_corner_old.x() + kx, top_left_window_corner_old.y() + ky, - iw00_old, iw01_old, iw10_old, iw11_old, W_BITS - 5); - const int32_t jval = get_pixel(_input_new, top_left_window_corner_new.x() + kx, top_left_window_corner_new.y() + ky, - iw00_new, iw01_new, iw10_new, iw11_new, W_BITS - 5); - - const int32_t diff = jval - ival; - - ib1 += diff * bilinear_ix[kx + ky * _window_dimension]; - ib2 += diff * bilinear_iy[kx + ky * _window_dimension]; - } - } - - ib1 += vgetq_lane_s32(nb1, 0) + vgetq_lane_s32(nb1, 1) + vgetq_lane_s32(nb1, 2) + vgetq_lane_s32(nb1, 3); - ib2 += vgetq_lane_s32(nb2, 0) + vgetq_lane_s32(nb2, 1) + vgetq_lane_s32(nb2, 2) + vgetq_lane_s32(nb2, 3); - - return std::make_pair(ib1, ib2); -} - -NELKTrackerKernel::NELKTrackerKernel() - : _input_old(nullptr), _input_new(nullptr), _old_scharr_gx(nullptr), _old_scharr_gy(nullptr), _new_points(nullptr), _new_points_estimates(nullptr), _old_points(nullptr), _old_points_internal(), - _new_points_internal(), _termination(Termination::TERM_CRITERIA_EPSILON), _use_initial_estimate(false), _pyramid_scale(0.0f), _epsilon(0.0f), _num_iterations(0), _window_dimension(0), _level(0), - _num_levels(0), _valid_region() -{ -} - -BorderSize NELKTrackerKernel::border_size() const -{ - return BorderSize(1); -} - -void NELKTrackerKernel::configure(const ITensor *input_old, const ITensor *input_new, const ITensor *old_scharr_gx, const ITensor *old_scharr_gy, - const IKeyPointArray *old_points, const IKeyPointArray *new_points_estimates, IKeyPointArray *new_points, - INELKInternalKeypointArray *old_points_internal, INELKInternalKeypointArray *new_points_internal, - Termination termination, bool use_initial_estimate, float epsilon, unsigned int num_iterations, size_t window_dimension, - size_t level, size_t num_levels, float pyramid_scale) - -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input_old, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input_new, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_scharr_gx, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_scharr_gy, 1, DataType::S16); - - _input_old = input_old; - _input_new = input_new; - _old_scharr_gx = old_scharr_gx; - _old_scharr_gy = old_scharr_gy; - _old_points = old_points; - _new_points_estimates = new_points_estimates; - _new_points = new_points; - _old_points_internal = old_points_internal; - _new_points_internal = new_points_internal; - _termination = termination; - _use_initial_estimate = use_initial_estimate; - _epsilon = epsilon; - _window_dimension = window_dimension; - _level = level; - _num_levels = num_levels; - _pyramid_scale = pyramid_scale; - _num_levels = num_levels; - - // Set maximum number of iterations used for convergence - const size_t max_iterations = 1000; - _num_iterations = (termination == Termination::TERM_CRITERIA_EPSILON) ? max_iterations : num_iterations; - - Window window; - window.set(Window::DimX, Window::Dimension(0, old_points->num_values())); - window.set(Window::DimY, Window::Dimension(0, 1)); - - _valid_region = intersect_valid_regions( - input_old->info()->valid_region(), - input_new->info()->valid_region(), - old_scharr_gx->info()->valid_region(), - old_scharr_gy->info()->valid_region()); - - update_window_and_padding(window, - AccessWindowStatic(input_old->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1)), - AccessWindowStatic(input_new->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1)), - AccessWindowStatic(old_scharr_gx->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1)), - AccessWindowStatic(old_scharr_gy->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1))); - - INEKernel::configure(window); -} - -void NELKTrackerKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - - ARM_COMPUTE_ERROR_ON(_input_old->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_input_new->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_old_scharr_gx->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_old_scharr_gy->buffer() == nullptr); - - const int list_end = window.x().end(); - const int list_start = window.x().start(); - - init_keypoints(list_start, list_end); - - const int buffer_size = _window_dimension * _window_dimension; - std::vector bilinear_ix(buffer_size); - std::vector bilinear_iy(buffer_size); - - const int half_window = _window_dimension / 2; - - auto is_invalid_keypoint = [&](const NELKInternalKeypoint & keypoint) - { - const int x = std::floor(keypoint.x); - const int y = std::floor(keypoint.y); - - return (x - half_window < _valid_region.start(0)) || (x + half_window >= _valid_region.end(0) - 1) || (y - half_window < _valid_region.start(1)) || (y + half_window >= _valid_region.end(1) - 1); - }; - - for(int list_indx = list_start; list_indx < list_end; ++list_indx) - { - NELKInternalKeypoint &old_keypoint = _old_points_internal->at(list_indx); - NELKInternalKeypoint &new_keypoint = _new_points_internal->at(list_indx); - - if(!old_keypoint.tracking_status) - { - continue; - } - - if(is_invalid_keypoint(old_keypoint)) - { - if(_level == 0) - { - new_keypoint.tracking_status = false; - } - - continue; - } - - // Compute spatial gradient matrix - int iA11 = 0; - int iA12 = 0; - int iA22 = 0; - - std::tie(iA11, iA12, iA22) = compute_spatial_gradient_matrix(old_keypoint, bilinear_ix.data(), bilinear_iy.data()); - - const float A11 = iA11 * FLT_SCALE; - const float A12 = iA12 * FLT_SCALE; - const float A22 = iA22 * FLT_SCALE; - - // Calculate minimum eigenvalue - const float sum_A11_A22 = A11 + A22; - const float discriminant = sum_A11_A22 * sum_A11_A22 - 4.0f * (A11 * A22 - A12 * A12); - // Divide by _window_dimension^2 to reduce the floating point accummulation error - const float minimum_eigenvalue = (sum_A11_A22 - std::sqrt(discriminant)) / (2.0f * _window_dimension * _window_dimension); - - // Determinant - const double D = A11 * A22 - A12 * A12; - - // Check if it is a good point to track - if(minimum_eigenvalue < EIGENVALUE_THRESHOLD || D < DETERMINANT_THRESHOLD) - { - // Invalidate tracked point - if(_level == 0) - { - new_keypoint.tracking_status = false; - } - - continue; - } - - float prev_delta_x = 0.0f; - float prev_delta_y = 0.0f; - - for(unsigned int j = 0; j < _num_iterations; ++j) - { - if(is_invalid_keypoint(new_keypoint)) - { - if(_level == 0) - { - new_keypoint.tracking_status = false; - } - - break; - } - - // Compute image mismatch vector - int ib1 = 0; - int ib2 = 0; - - std::tie(ib1, ib2) = compute_image_mismatch_vector(old_keypoint, new_keypoint, bilinear_ix.data(), bilinear_iy.data()); - - double b1 = ib1 * FLT_SCALE; - double b2 = ib2 * FLT_SCALE; - - // Compute motion vector -> A^-1 * -b - const float delta_x = (A12 * b2 - A22 * b1) / D; - const float delta_y = (A12 * b1 - A11 * b2) / D; - - // Update the new position - new_keypoint.x += delta_x; - new_keypoint.y += delta_y; - - const float mag2 = delta_x * delta_x + delta_y * delta_y; - - // Check if termination criteria is EPSILON and if it is satisfied - if(mag2 <= _epsilon && (_termination == Termination::TERM_CRITERIA_EPSILON || _termination == Termination::TERM_CRITERIA_BOTH)) - { - break; - } - - // Check convergence analyzing the previous delta - if(j > 0 && std::fabs(delta_x + prev_delta_x) < 0.01f && std::fabs(delta_y + prev_delta_y) < 0.01f) - { - new_keypoint.x -= delta_x * _pyramid_scale; - new_keypoint.y -= delta_y * _pyramid_scale; - break; - } - - prev_delta_x = delta_x; - prev_delta_y = delta_y; - } - } - - if(_level == 0) - { - for(int list_indx = list_start; list_indx < list_end; ++list_indx) - { - const NELKInternalKeypoint &new_keypoint = _new_points_internal->at(list_indx); - - _new_points->at(list_indx).x = roundf(new_keypoint.x); - _new_points->at(list_indx).y = roundf(new_keypoint.y); - _new_points->at(list_indx).tracking_status = new_keypoint.tracking_status ? 1 : 0; - } - } -} diff --git a/src/core/NEON/kernels/NELKTrackerKernel.h b/src/core/NEON/kernels/NELKTrackerKernel.h deleted file mode 100644 index bc4f6ce296..0000000000 --- a/src/core/NEON/kernels/NELKTrackerKernel.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2016-2021 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_LKTRACKERKERNEL_H -#define ARM_COMPUTE_LKTRACKERKERNEL_H - -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/Types.h" -#include "src/core/NEON/INEKernel.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -class ITensor; - -/** Interface for Neon Array of Internal Key Points. */ -using INELKInternalKeypointArray = IArray; - -/** Interface for the Lucas-Kanade tracker kernel */ -class NELKTrackerKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NELKTrackerKernel"; - } - /** Default constructor */ - NELKTrackerKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NELKTrackerKernel(const NELKTrackerKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NELKTrackerKernel &operator=(const NELKTrackerKernel &) = delete; - /** Allow instances of this class to be moved */ - NELKTrackerKernel(NELKTrackerKernel &&) = default; - /** Allow instances of this class to be moved */ - NELKTrackerKernel &operator=(NELKTrackerKernel &&) = default; - /** Default destructor */ - ~NELKTrackerKernel() = default; - - /** Initialise the kernel input and output - * - * @param[in] input_old Pointer to the input old tensor. Data type supported: U8 - * @param[in] input_new Pointer to the input new tensor. Data type supported. U8 - * @param[in] old_scharr_gx Pointer to the input scharr X tensor. Data type supported: S16 - * @param[in] old_scharr_gy Pointer to the input scharr Y tensor. Data type supported: S16 - * @param[in] old_points Pointer to the IKeyPointArray storing old key points - * @param[in] new_points_estimates Pointer to the IKeyPointArray storing new estimates key points - * @param[out] new_points Pointer to the IKeyPointArray storing new key points - * @param[in, out] old_points_internal Pointer to the array of NELKInternalKeypoint for old points - * @param[out] new_points_internal Pointer to the array of NELKInternalKeypoint for new points - * @param[in] termination The criteria to terminate the search of each keypoint. - * @param[in] use_initial_estimate The flag to indicate whether the initial estimated position should be used - * @param[in] epsilon The error for terminating the algorithm - * @param[in] num_iterations The maximum number of iterations before terminate the algorithm - * @param[in] window_dimension The size of the window on which to perform the algorithm - * @param[in] level The pyramid level - * @param[in] num_levels The number of pyramid levels - * @param[in] pyramid_scale Scale factor used for generating the pyramid - */ - void configure(const ITensor *input_old, const ITensor *input_new, const ITensor *old_scharr_gx, const ITensor *old_scharr_gy, - const IKeyPointArray *old_points, const IKeyPointArray *new_points_estimates, IKeyPointArray *new_points, - INELKInternalKeypointArray *old_points_internal, INELKInternalKeypointArray *new_points_internal, - Termination termination, bool use_initial_estimate, float epsilon, unsigned int num_iterations, size_t window_dimension, - size_t level, size_t num_levels, float pyramid_scale); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - BorderSize border_size() const override; - -private: - /** Initialise the array of keypoints in the provide range - * - * @param[in] start Index of first element in the keypoints array to be initialised - * @param[in] end Index after last elelemnt in the keypoints array to be initialised - */ - void init_keypoints(int start, int end); - /** Compute the structure tensor A^T * A based on the scharr gradients I_x and I_y - * - * @param[in] keypoint Keypoint for which gradients are computed - * @param[out] bilinear_ix Intermediate interpolated data for X gradient - * @param[out] bilinear_iy Intermediate interpolated data for Y gradient - * - * @return Values A11, A12, A22 - */ - std::tuple compute_spatial_gradient_matrix(const NELKInternalKeypoint &keypoint, int32_t *bilinear_ix, int32_t *bilinear_iy); - /** Compute the vector A^T * b, i.e. -sum(I_d * I_t) for d in {x,y} - * - * @param[in] old_keypoint Old keypoint for which gradient is computed - * @param[in] new_keypoint New keypoint for which gradient is computed - * @param[in] bilinear_ix Intermediate interpolated data for X gradient - * @param[in] bilinear_iy Intermediate interpolated data for Y gradient - * - * @return Values b1, b2 - */ - std::pair compute_image_mismatch_vector(const NELKInternalKeypoint &old_keypoint, const NELKInternalKeypoint &new_keypoint, const int32_t *bilinear_ix, const int32_t *bilinear_iy); - - const ITensor *_input_old; - const ITensor *_input_new; - const ITensor *_old_scharr_gx; - const ITensor *_old_scharr_gy; - IKeyPointArray *_new_points; - const IKeyPointArray *_new_points_estimates; - const IKeyPointArray *_old_points; - INELKInternalKeypointArray *_old_points_internal; - INELKInternalKeypointArray *_new_points_internal; - Termination _termination; - bool _use_initial_estimate; - float _pyramid_scale; - float _epsilon; - unsigned int _num_iterations; - int _window_dimension; - unsigned int _level; - unsigned int _num_levels; - ValidRegion _valid_region; -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_NELKTRACKERKERNEL_H */ diff --git a/src/core/NEON/kernels/NEROIPoolingLayerKernel.h b/src/core/NEON/kernels/NEROIPoolingLayerKernel.h index 2fcdb81eb6..e7a7e90eef 100644 --- a/src/core/NEON/kernels/NEROIPoolingLayerKernel.h +++ b/src/core/NEON/kernels/NEROIPoolingLayerKernel.h @@ -25,9 +25,6 @@ #define ARM_COMPUTE_NEROIPOOLINGLAYERKERNEL_H #include "src/core/NEON/INEKernel.h" - -#include "arm_compute/core/IArray.h" - namespace arm_compute { class ITensor; @@ -90,7 +87,7 @@ public: private: const ITensor *_input; const ITensor *_rois; - const ITensor *_output; + const ITensor *_output; ROIPoolingLayerInfo _pool_info; }; } // namespace arm_compute -- cgit v1.2.1