• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016-2020 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_CLFASTCORNERS_H
25 #define ARM_COMPUTE_CLFASTCORNERS_H
26 
27 #include "arm_compute/core/CL/OpenCL.h"
28 #include "arm_compute/core/Types.h"
29 #include "arm_compute/core/Window.h"
30 #include "arm_compute/runtime/CL/CLArray.h"
31 #include "arm_compute/runtime/CL/CLTensor.h"
32 #include "arm_compute/runtime/CL/functions/CLNonMaximaSuppression3x3.h"
33 #include "arm_compute/runtime/IFunction.h"
34 #include "arm_compute/runtime/IMemoryManager.h"
35 #include "arm_compute/runtime/MemoryGroup.h"
36 
37 #include <cstdint>
38 #include <memory>
39 
40 namespace arm_compute
41 {
42 class CLFastCornersKernel;
43 class CLCopyToArrayKernel;
44 class ICLTensor;
45 using ICLImage = ICLTensor;
46 
47 /** Basic function to execute fast corners. This function calls the following CL kernels:
48  *
49  * -# @ref CLFastCornersKernel
50  * -# @ref CLNonMaximaSuppression3x3Kernel (executed if nonmax_suppression == true)
51  * -# @ref CLCopyToArrayKernel
52  *
53  * @deprecated This function is deprecated and is intended to be removed in 21.05 release
54  *
55  */
56 class CLFastCorners : public IFunction
57 {
58 public:
59     /** Constructor */
60     CLFastCorners(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
61     /** Prevent instances of this class from being copied (As this class contains pointers) */
62     CLFastCorners(const CLFastCorners &) = delete;
63     /** Prevent instances of this class from being copied (As this class contains pointers) */
64     const CLFastCorners &operator=(const CLFastCorners &) = delete;
65     /** Default destructor */
66     ~CLFastCorners();
67     /** Initialize the function's source, destination, conv and border_mode.
68      *
69      * @param[in]     input                 Source image. Data types supported: U8.
70      * @param[in]     threshold             Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle of radius 3.
71      * @param[in]     nonmax_suppression    If true, non-maximum suppression is applied to detected corners before being placed in the array.
72      * @param[out]    corners               Array of keypoints to store the results.
73      * @param[in,out] num_corners           Record number of corners in the array
74      * @param[in]     border_mode           Strategy to use for borders.
75      * @param[in]     constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
76      */
77     void configure(const ICLImage *input, float threshold, bool nonmax_suppression, ICLKeyPointArray *corners, unsigned int *num_corners,
78                    BorderMode border_mode, uint8_t constant_border_value = 0);
79     /** Initialize the function's source, destination, conv and border_mode.
80      *
81      * @param[in]     compile_context       The compile context to be used.
82      * @param[in]     input                 Source image. Data types supported: U8.
83      * @param[in]     threshold             Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle of radius 3.
84      * @param[in]     nonmax_suppression    If true, non-maximum suppression is applied to detected corners before being placed in the array.
85      * @param[out]    corners               Array of keypoints to store the results.
86      * @param[in,out] num_corners           Record number of corners in the array
87      * @param[in]     border_mode           Strategy to use for borders.
88      * @param[in]     constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
89      */
90     void configure(const CLCompileContext &compile_context, const ICLImage *input, float threshold, bool nonmax_suppression, ICLKeyPointArray *corners, unsigned int *num_corners,
91                    BorderMode border_mode, uint8_t constant_border_value = 0);
92     // Inherited methods overridden:
93     void run() override;
94 
95 private:
96     MemoryGroup                          _memory_group;
97     std::unique_ptr<CLFastCornersKernel> _fast_corners_kernel;
98     CLNonMaximaSuppression3x3            _suppr_func;
99     std::unique_ptr<CLCopyToArrayKernel> _copy_array_kernel;
100     CLImage                              _output;
101     CLImage                              _suppr;
102     Window                               _win;
103     bool                                 _non_max;
104     unsigned int                        *_num_corners;
105     cl::Buffer                           _num_buffer;
106     ICLKeyPointArray                    *_corners;
107     uint8_t                              _constant_border_value;
108 };
109 }
110 #endif /*ARM_COMPUTE_CLFASTCORNERS_H */
111