blob: dbe0ecdf6670b5abc70452558821973658501eef [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 2017 ARM Limited.
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 */
24#ifndef __ARM_COMPUTE_NEGAUSSIANPYRAMID_H__
25#define __ARM_COMPUTE_NEGAUSSIANPYRAMID_H__
26
27#include "arm_compute/core/IPyramid.h"
28#include "arm_compute/core/NEON/kernels/NEGaussianPyramidKernel.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#include "arm_compute/core/Types.h"
30#include "arm_compute/runtime/IFunction.h"
31#include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h"
Georgios Pinitas3021edf2017-09-18 17:55:22 +010032#include "arm_compute/runtime/NEON/functions/NEScale.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033#include "arm_compute/runtime/Pyramid.h"
34#include "arm_compute/runtime/Tensor.h"
35
36#include <cstdint>
37#include <memory>
38
39namespace arm_compute
40{
41class ITensor;
42
43/** Common interface for all Gaussian pyramid functions */
44class NEGaussianPyramid : public IFunction
45{
46public:
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
70protected:
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 */
83class NEGaussianPyramidHalf : public NEGaussianPyramid
84{
85public:
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
93private:
Gian Marco37908d92017-11-07 14:38:22 +000094 std::unique_ptr<NEFillBorderKernel[]> _horizontal_border_handler;
95 std::unique_ptr<NEFillBorderKernel[]> _vertical_border_handler;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010096 std::unique_ptr<NEGaussianPyramidHorKernel[]> _horizontal_reduction;
97 std::unique_ptr<NEGaussianPyramidVertKernel[]> _vertical_reduction;
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 */
107class NEGaussianPyramidOrb : public NEGaussianPyramid
108{
109public:
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
117private:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100118 std::unique_ptr<NEGaussian5x5[]> _gaus5x5;
Georgios Pinitas3021edf2017-09-18 17:55:22 +0100119 std::unique_ptr<NEScale[]> _scale_nearest;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100120};
121}
122#endif /*__ARM_COMPUTE_NEGAUSSIANPYRAMID_H__ */