Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2019 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_NEGAUSSIANPYRAMID_H |
| 25 | #define ARM_COMPUTE_NEGAUSSIANPYRAMID_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/IPyramid.h" |
| 28 | #include "arm_compute/core/NEON/kernels/NEGaussianPyramidKernel.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Types.h" |
| 30 | #include "arm_compute/runtime/IFunction.h" |
| 31 | #include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h" |
Georgios Pinitas | 3021edf | 2017-09-18 17:55:22 +0100 | [diff] [blame] | 32 | #include "arm_compute/runtime/NEON/functions/NEScale.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | #include "arm_compute/runtime/Pyramid.h" |
| 34 | #include "arm_compute/runtime/Tensor.h" |
| 35 | |
| 36 | #include <cstdint> |
| 37 | #include <memory> |
| 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | class ITensor; |
| 42 | |
| 43 | /** Common interface for all Gaussian pyramid functions */ |
| 44 | class NEGaussianPyramid : public IFunction |
| 45 | { |
| 46 | public: |
| 47 | /** Default constructor */ |
| 48 | NEGaussianPyramid(); |
| 49 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 50 | NEGaussianPyramid(const NEGaussianPyramid &) = delete; |
| 51 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 52 | NEGaussianPyramid &operator=(const NEGaussianPyramid &) = delete; |
| 53 | /** Allow instances of this class to be moved */ |
| 54 | NEGaussianPyramid(NEGaussianPyramid &&) = default; |
| 55 | /** Allow instances of this class to be moved */ |
| 56 | NEGaussianPyramid &operator=(NEGaussianPyramid &&) = default; |
| 57 | /** Default destructor */ |
| 58 | virtual ~NEGaussianPyramid() = default; |
| 59 | |
| 60 | /** Initialise the function's source, destinations and border mode. |
| 61 | * |
| 62 | * @param[in] input Source tensor. Data type supported: U8. |
| 63 | * @param[out] pyramid Destination pyramid tensors, Data type supported at each level: U8. |
| 64 | * @param[in] border_mode Border mode to use. |
| 65 | * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. |
| 66 | * |
| 67 | */ |
| 68 | virtual void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) = 0; |
| 69 | |
| 70 | protected: |
| 71 | const ITensor *_input; |
| 72 | IPyramid *_pyramid; |
| 73 | Pyramid _tmp; |
| 74 | }; |
| 75 | |
| 76 | /** Basic function to execute gaussian pyramid with HALF scale factor. This function calls the following NEON kernels: |
| 77 | * |
| 78 | * -# @ref NEFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE) |
| 79 | * -# @ref NEGaussianPyramidHorKernel |
| 80 | * -# @ref NEGaussianPyramidVertKernel |
| 81 | * |
| 82 | */ |
| 83 | class NEGaussianPyramidHalf : public NEGaussianPyramid |
| 84 | { |
| 85 | public: |
| 86 | /** Constructor */ |
| 87 | NEGaussianPyramidHalf(); |
| 88 | |
| 89 | // Inherited methods overridden: |
| 90 | void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override; |
| 91 | void run() override; |
| 92 | |
| 93 | private: |
Georgios Pinitas | 725b173 | 2019-05-20 19:40:47 +0100 | [diff] [blame] | 94 | std::vector<NEFillBorderKernel> _horizontal_border_handler; |
| 95 | std::vector<NEFillBorderKernel> _vertical_border_handler; |
| 96 | std::vector<NEGaussianPyramidHorKernel> _horizontal_reduction; |
| 97 | std::vector<NEGaussianPyramidVertKernel> _vertical_reduction; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | /** Basic function to execute gaussian pyramid with ORB scale factor. This function calls the following NEON kernels and functions: |
| 101 | * |
| 102 | * -# @ref NEFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE) |
| 103 | * -# @ref NEGaussian5x5 |
| 104 | * -# @ref NEScaleKernel |
| 105 | * |
| 106 | */ |
| 107 | class NEGaussianPyramidOrb : public NEGaussianPyramid |
| 108 | { |
| 109 | public: |
| 110 | /** Constructor */ |
| 111 | NEGaussianPyramidOrb(); |
| 112 | |
| 113 | // Inherited methods overridden: |
| 114 | void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override; |
| 115 | void run() override; |
| 116 | |
| 117 | private: |
Georgios Pinitas | 725b173 | 2019-05-20 19:40:47 +0100 | [diff] [blame] | 118 | std::vector<NEGaussian5x5> _gaus5x5; |
| 119 | std::vector<NEScale> _scale_nearest; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 120 | }; |
Georgios Pinitas | 725b173 | 2019-05-20 19:40:47 +0100 | [diff] [blame] | 121 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 122 | #endif /*ARM_COMPUTE_NEGAUSSIANPYRAMID_H */ |