blob: 6482b0aa4ef1e489547cb731a9ad29e5d894955c [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_CLHARRISCORNERSKERNEL_H
25#define ARM_COMPUTE_CLHARRISCORNERSKERNEL_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010027#include "src/core/CL/ICLKernel.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028
29#include <cstdint>
30
31namespace arm_compute
32{
33class ICLTensor;
34using ICLImage = ICLTensor;
35
36/** Interface for the harris score kernel.
37 *
38 * @note The implementation supports 3, 5, and 7 for the block_size.
39 */
40class CLHarrisScoreKernel : public ICLKernel
41{
42public:
43 /** Default constructor */
44 CLHarrisScoreKernel();
45 /** Prevent instances of this class from being copied (As this class contains pointers) */
46 CLHarrisScoreKernel(const CLHarrisScoreKernel &) = delete;
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 CLHarrisScoreKernel &operator=(const CLHarrisScoreKernel &) = delete;
49 /** Allow instances of this class to be moved */
50 CLHarrisScoreKernel(CLHarrisScoreKernel &&) = default;
51 /** Allow instances of this class to be moved */
52 CLHarrisScoreKernel &operator=(CLHarrisScoreKernel &&) = default;
53 /** Default destructor */
54 ~CLHarrisScoreKernel() = default;
55
56 /** Setup the kernel parameters
57 *
58 * @param[in] input1 Source image (gradient X). Data types supported S16, S32. (Must be the same as input2)
59 * @param[in] input2 Source image (gradient Y). Data types supported S16, S32. (Must be the same as input1)
60 * @param[out] output Destination image (harris score). Data types supported F32
61 * @param[in] block_size The block window size used to compute the Harris Corner score. Supports: 3, 5 and 7
62 * @param[in] norm_factor Normalization factor to use accordingly with the gradient size (Must be different from 0)
63 * @param[in] strength_thresh Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel).
64 * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation.
65 * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant.
66 */
67 void configure(const ICLImage *input1, const ICLImage *input2, ICLImage *output,
68 int32_t block_size, float norm_factor, float strength_thresh, float sensitivity,
69 bool border_undefined);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010070 /** Setup the kernel parameters
71 *
72 * @param[in] compile_context The compile context to be used.
73 * @param[in] input1 Source image (gradient X). Data types supported S16, S32. (Must be the same as input2)
74 * @param[in] input2 Source image (gradient Y). Data types supported S16, S32. (Must be the same as input1)
75 * @param[out] output Destination image (harris score). Data types supported F32
76 * @param[in] block_size The block window size used to compute the Harris Corner score. Supports: 3, 5 and 7
77 * @param[in] norm_factor Normalization factor to use accordingly with the gradient size (Must be different from 0)
78 * @param[in] strength_thresh Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel).
79 * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation.
80 * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant.
81 */
Manuel Bottini679fc962020-04-21 16:08:53 +010082 void configure(const CLCompileContext &compile_context, const ICLImage *input1, const ICLImage *input2, ICLImage *output,
Manuel Bottini4c6bd512020-04-08 10:15:51 +010083 int32_t block_size, float norm_factor, float strength_thresh, float sensitivity,
84 bool border_undefined);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010085
86 // Inherited methods overridden:
87 void run(const Window &window, cl::CommandQueue &queue) override;
88 BorderSize border_size() const override;
89
90protected:
91 const ICLImage *_input1; /**< Source image - Gx component */
92 const ICLImage *_input2; /**< Source image - Gy component */
93 ICLImage *_output; /**< Source image - Harris score */
94 float _sensitivity; /**< Sensitivity value */
95 float _strength_thresh; /**< Threshold value */
96 float _norm_factor; /**< Normalization factor */
97 BorderSize _border_size; /**< Border size */
98};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +010099} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000100#endif /* ARM_COMPUTE_CLHARRISCORNERSKERNEL_H */