Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2020 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_NEHARRISCORNERSKERNEL_H |
| 25 | #define ARM_COMPUTE_NEHARRISCORNERSKERNEL_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h" |
| 28 | #include "arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h" |
| 29 | #include "arm_compute/core/IArray.h" |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 30 | #include "src/core/NEON/INEKernel.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | |
| 32 | #include <cstdint> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | class ITensor; |
| 37 | using IImage = ITensor; |
| 38 | |
| 39 | /** Common interface for all Harris Score kernels */ |
| 40 | class INEHarrisScoreKernel : public INEKernel |
| 41 | { |
| 42 | public: |
| 43 | /** Default constructor */ |
| 44 | INEHarrisScoreKernel(); |
| 45 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 46 | INEHarrisScoreKernel(const INEHarrisScoreKernel &) = delete; |
| 47 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 48 | INEHarrisScoreKernel &operator=(const INEHarrisScoreKernel &) = delete; |
| 49 | /** Allow instances of this class to be moved */ |
| 50 | INEHarrisScoreKernel(INEHarrisScoreKernel &&) = default; |
| 51 | /** Allow instances of this class to be moved */ |
| 52 | INEHarrisScoreKernel &operator=(INEHarrisScoreKernel &&) = default; |
| 53 | /** Default destructor */ |
| 54 | ~INEHarrisScoreKernel() = default; |
| 55 | |
| 56 | public: |
| 57 | /** Setup the kernel parameters |
| 58 | * |
| 59 | * @param[in] input1 Source image (gradient X). Data types supported: S16/S32 |
| 60 | * @param[in] input2 Source image (gradient Y). Data types supported: same as @ input1 |
| 61 | * @param[out] output Destination image (harris score). Data types supported: F32 |
| 62 | * @param[in] norm_factor Normalization factor to use accordingly with the gradient size (Must be different from 0) |
| 63 | * @param[in] strength_thresh Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). |
| 64 | * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation |
| 65 | * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant. |
| 66 | */ |
| 67 | virtual void configure(const IImage *input1, const IImage *input2, IImage *output, float norm_factor, float strength_thresh, float sensitivity, bool border_undefined) = 0; |
| 68 | |
| 69 | protected: |
| 70 | const IImage *_input1; /**< Source image - Gx component */ |
| 71 | const IImage *_input2; /**< Source image - Gy component */ |
| 72 | IImage *_output; /**< Source image - Harris score */ |
| 73 | float _sensitivity; /**< Sensitivity value */ |
| 74 | float _strength_thresh; /**< Threshold value */ |
| 75 | float _norm_factor; /**< Normalization factor */ |
| 76 | BorderSize _border_size; /**< Border size */ |
| 77 | }; |
| 78 | |
| 79 | /** Template NEON kernel to perform Harris Score. |
| 80 | * The implementation supports 3, 5, and 7 for the block_size |
| 81 | */ |
| 82 | template <int32_t block_size> |
| 83 | class NEHarrisScoreKernel : public INEHarrisScoreKernel |
| 84 | { |
| 85 | public: |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 86 | const char *name() const override |
| 87 | { |
| 88 | return "NEHarrisScoreKernel"; |
| 89 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 90 | /** Default constructor */ |
| 91 | NEHarrisScoreKernel(); |
| 92 | // Inherited methods overridden: |
| 93 | void configure(const IImage *input1, const IImage *input2, IImage *output, float norm_factor, float strength_thresh, float sensitivity, bool border_undefined) override; |
| 94 | BorderSize border_size() const override; |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 95 | void run(const Window &window, const ThreadInfo &info) override; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 96 | |
| 97 | private: |
| 98 | /** Common signature for all the specialised harris score functions */ |
| 99 | using HarrisScoreFunction = void(const void *__restrict input1_ptr, const void *__restrict input2_ptr, void *__restrict output_ptr, int32_t input_stride, |
| 100 | float norm_factor, float sensitivity, float strength_thresh); |
| 101 | /** Harris Score function to use for the particular image types passed to configure() */ |
| 102 | HarrisScoreFunction *_func; |
| 103 | }; |
Gian Marco Iodice | 356f643 | 2017-09-22 11:32:21 +0100 | [diff] [blame] | 104 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 105 | #endif /* ARM_COMPUTE_NEHARRISCORNERSKERNEL_H */ |