blob: 5d0da7d5d5a46695054ad4b3e2b975664ef4071f [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2016-2020 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_CLFASTCORNERSKERNEL_H
25#define ARM_COMPUTE_CLFASTCORNERSKERNEL_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/CL/ICLArray.h"
28#include "arm_compute/core/CL/ICLKernel.h"
29#include "arm_compute/core/Types.h"
30
31#include <cstdint>
32
33namespace cl
34{
35class Buffer;
36}
37
38namespace arm_compute
39{
40class ICLTensor;
41using ICLImage = ICLTensor;
42
43/** CL kernel to perform fast corners */
44class CLFastCornersKernel : public ICLKernel
45{
46public:
47 /** Default constructor */
48 CLFastCornersKernel();
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 CLFastCornersKernel(const CLFastCornersKernel &) = delete;
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 CLFastCornersKernel &operator=(const CLFastCornersKernel &) = delete;
53 /** Allow instances of this class to be moved */
54 CLFastCornersKernel(CLFastCornersKernel &&) = default;
55 /** Allow instances of this class to be moved */
56 CLFastCornersKernel &operator=(CLFastCornersKernel &&) = default;
57 /** Default destructor */
58 ~CLFastCornersKernel() = default;
59
60 /** Initialise the kernel.
61 *
62 * @param[in] input Source image. Data types supported: U8.
63 * @param[out] output Output image. Data types supported: U8.
64 * @param[in] threshold Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle of radius 3.
65 * @param[in] non_max_suppression True if non-maxima suppresion is applied, false otherwise.
66 * @param[in] border_mode Strategy to use for borders.
67 */
68 void configure(const ICLImage *input, ICLImage *output, float threshold, bool non_max_suppression, BorderMode border_mode);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010069 /** Initialise the kernel.
70 *
71 * @param[in] compile_context The compile context to be used.
72 * @param[in] input Source image. Data types supported: U8.
73 * @param[out] output Output image. Data types supported: U8.
74 * @param[in] threshold Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle of radius 3.
75 * @param[in] non_max_suppression True if non-maxima suppresion is applied, false otherwise.
76 * @param[in] border_mode Strategy to use for borders.
77 */
Manuel Bottini256c0b92020-04-21 13:29:30 +010078 void configure(const CLCompileContext &compile_context, const ICLImage *input, ICLImage *output, float threshold, bool non_max_suppression, BorderMode border_mode);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079
80 // Inherited methods overridden
81 void run(const Window &window, cl::CommandQueue &queue) override;
82 BorderSize border_size() const override;
83
84private:
85 const ICLImage *_input;
86 ICLImage *_output;
87};
88
89/** CL kernel to copy keypoints information to ICLKeyPointArray and counts the number of key points */
90class CLCopyToArrayKernel : public ICLKernel
91{
92public:
93 /** Default constructor */
94 CLCopyToArrayKernel();
95 /** Prevent instances of this class from being copied (As this class contains pointers) */
96 CLCopyToArrayKernel(const CLCopyToArrayKernel &) = delete;
97 /** Prevent instances of this class from being copied (As this class contains pointers) */
98 CLCopyToArrayKernel &operator=(const CLCopyToArrayKernel &) = delete;
99 /** Allow instances of this class to be moved */
100 CLCopyToArrayKernel(CLCopyToArrayKernel &&) = default;
101 /** Allow instances of this class to be moved */
102 CLCopyToArrayKernel &operator=(CLCopyToArrayKernel &&) = default;
103 /** Default destructor */
104 ~CLCopyToArrayKernel() = default;
105
106 /** Initialise the kernel.
107 *
108 * @param[in] input Source image. Data types supported: U8.
109 * @param[in] update_number Flag to indicate whether we need to update the number of corners
110 * @param[out] corners Array of keypoints to store the results.
111 * @param[out] num_buffers Number of keypoints to store the results.
112 */
113 void configure(const ICLImage *input, bool update_number, ICLKeyPointArray *corners, cl::Buffer *num_buffers);
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100114 /** Initialise the kernel.
115 *
116 * @param[in] compile_context The compile context to be used.
117 * @param[in] input Source image. Data types supported: U8.
118 * @param[in] update_number Flag to indicate whether we need to update the number of corners
119 * @param[out] corners Array of keypoints to store the results.
120 * @param[out] num_buffers Number of keypoints to store the results.
121 */
Manuel Bottini256c0b92020-04-21 13:29:30 +0100122 void configure(const CLCompileContext &compile_context, const ICLImage *input, bool update_number, ICLKeyPointArray *corners, cl::Buffer *num_buffers);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100123
124 // Inherited methods overridden:
125 void run(const Window &window, cl::CommandQueue &queue) override;
126
127private:
128 const ICLImage *_input; /**< source image */
129 ICLKeyPointArray *_corners; /**< destination array */
130 cl::Buffer *_num_buffer; /**< CL memory to record number of key points in the array */
131};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +0100132} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000133#endif /* ARM_COMPUTE_CLFASTCORNERSKERNEL_H */