blob: 2a0e0104b8c503f29943b18ee22697009ead1435 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Georgios Pinitas26014cf2019-09-09 19:00:57 +01002 * Copyright (c) 2016-2019 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_CLFASTCORNERS_H
25#define ARM_COMPUTE_CLFASTCORNERS_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/CL/OpenCL.h"
28#include "arm_compute/core/CL/kernels/CLFastCornersKernel.h"
29#include "arm_compute/core/Types.h"
30#include "arm_compute/core/Window.h"
31#include "arm_compute/runtime/CL/CLArray.h"
32#include "arm_compute/runtime/CL/CLTensor.h"
33#include "arm_compute/runtime/CL/functions/CLNonMaximaSuppression3x3.h"
34#include "arm_compute/runtime/IFunction.h"
Georgios Pinitas5701e2a2017-09-18 17:43:33 +010035#include "arm_compute/runtime/IMemoryManager.h"
Georgios Pinitas26014cf2019-09-09 19:00:57 +010036#include "arm_compute/runtime/MemoryGroup.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037
38#include <cstdint>
Georgios Pinitas5701e2a2017-09-18 17:43:33 +010039#include <memory>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040
41namespace arm_compute
42{
43class ICLTensor;
44using ICLImage = ICLTensor;
45
46/** Basic function to execute fast corners. This function calls the following CL kernels:
47 *
48 * -# @ref CLFastCornersKernel
49 * -# @ref CLNonMaximaSuppression3x3Kernel (executed if nonmax_suppression == true)
50 * -# @ref CLCopyToArrayKernel
51 *
52 */
53class CLFastCorners : public IFunction
54{
55public:
56 /** Constructor */
Georgios Pinitas5701e2a2017-09-18 17:43:33 +010057 CLFastCorners(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010058 /** Prevent instances of this class from being copied (As this class contains pointers) */
59 CLFastCorners(const CLFastCorners &) = delete;
60 /** Prevent instances of this class from being copied (As this class contains pointers) */
61 const CLFastCorners &operator=(const CLFastCorners &) = delete;
62 /** Initialize the function's source, destination, conv and border_mode.
63 *
64 * @param[in] input Source image. Data types supported: U8.
65 * @param[in] threshold Threshold on difference between intensity of the central pixel and pixels on Bresenham's circle of radius 3.
66 * @param[in] nonmax_suppression If true, non-maximum suppression is applied to detected corners before being placed in the array.
67 * @param[out] corners Array of keypoints to store the results.
68 * @param[in,out] num_corners Record number of corners in the array
69 * @param[in] border_mode Strategy to use for borders.
70 * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
71 */
Abe Mbise25a340f2017-12-19 13:00:58 +000072 void configure(const ICLImage *input, float threshold, bool nonmax_suppression, ICLKeyPointArray *corners, unsigned int *num_corners,
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073 BorderMode border_mode, uint8_t constant_border_value = 0);
74 // Inherited methods overridden:
75 void run() override;
76
77private:
Georgios Pinitas26014cf2019-09-09 19:00:57 +010078 MemoryGroup _memory_group;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079 CLFastCornersKernel _fast_corners_kernel;
80 CLNonMaximaSuppression3x3 _suppr_func;
81 CLCopyToArrayKernel _copy_array_kernel;
82 CLImage _output;
83 CLImage _suppr;
84 Window _win;
85 bool _non_max;
86 unsigned int *_num_corners;
87 cl::Buffer _num_buffer;
Abe Mbise25a340f2017-12-19 13:00:58 +000088 ICLKeyPointArray *_corners;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010089 uint8_t _constant_border_value;
90};
91}
Michalis Spyrouf4643372019-11-29 16:17:13 +000092#endif /*ARM_COMPUTE_CLFASTCORNERS_H */