Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2019 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_CLFASTCORNERSKERNEL_H |
| 25 | #define ARM_COMPUTE_CLFASTCORNERSKERNEL_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 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 | |
| 33 | namespace cl |
| 34 | { |
| 35 | class Buffer; |
| 36 | } |
| 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | class ICLTensor; |
| 41 | using ICLImage = ICLTensor; |
| 42 | |
| 43 | /** CL kernel to perform fast corners */ |
| 44 | class CLFastCornersKernel : public ICLKernel |
| 45 | { |
| 46 | public: |
| 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); |
| 69 | |
| 70 | // Inherited methods overridden |
| 71 | void run(const Window &window, cl::CommandQueue &queue) override; |
| 72 | BorderSize border_size() const override; |
| 73 | |
| 74 | private: |
| 75 | const ICLImage *_input; |
| 76 | ICLImage *_output; |
| 77 | }; |
| 78 | |
| 79 | /** CL kernel to copy keypoints information to ICLKeyPointArray and counts the number of key points */ |
| 80 | class CLCopyToArrayKernel : public ICLKernel |
| 81 | { |
| 82 | public: |
| 83 | /** Default constructor */ |
| 84 | CLCopyToArrayKernel(); |
| 85 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 86 | CLCopyToArrayKernel(const CLCopyToArrayKernel &) = delete; |
| 87 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 88 | CLCopyToArrayKernel &operator=(const CLCopyToArrayKernel &) = delete; |
| 89 | /** Allow instances of this class to be moved */ |
| 90 | CLCopyToArrayKernel(CLCopyToArrayKernel &&) = default; |
| 91 | /** Allow instances of this class to be moved */ |
| 92 | CLCopyToArrayKernel &operator=(CLCopyToArrayKernel &&) = default; |
| 93 | /** Default destructor */ |
| 94 | ~CLCopyToArrayKernel() = default; |
| 95 | |
| 96 | /** Initialise the kernel. |
| 97 | * |
| 98 | * @param[in] input Source image. Data types supported: U8. |
| 99 | * @param[in] update_number Flag to indicate whether we need to update the number of corners |
| 100 | * @param[out] corners Array of keypoints to store the results. |
| 101 | * @param[out] num_buffers Number of keypoints to store the results. |
| 102 | */ |
| 103 | void configure(const ICLImage *input, bool update_number, ICLKeyPointArray *corners, cl::Buffer *num_buffers); |
| 104 | |
| 105 | // Inherited methods overridden: |
| 106 | void run(const Window &window, cl::CommandQueue &queue) override; |
| 107 | |
| 108 | private: |
| 109 | const ICLImage *_input; /**< source image */ |
| 110 | ICLKeyPointArray *_corners; /**< destination array */ |
| 111 | cl::Buffer *_num_buffer; /**< CL memory to record number of key points in the array */ |
| 112 | }; |
Gian Marco Iodice | f670a0a | 2017-09-18 12:20:45 +0100 | [diff] [blame] | 113 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 114 | #endif /* ARM_COMPUTE_CLFASTCORNERSKERNEL_H */ |