blob: fa5b27952ff875f8476a3d08436cf1520b2dbd74 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 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_CLHOGDESCRIPTORKERNEL_H__
25#define __ARM_COMPUTE_CLHOGDESCRIPTORKERNEL_H__
26
27#include "arm_compute/core/CL/ICLKernel.h"
28#include "arm_compute/core/IHOG.h"
29#include "arm_compute/core/Size2D.h"
30
31namespace arm_compute
32{
33class ITensor;
34
35/** OpenCL kernel to perform HOG Orientation Binning */
36class CLHOGOrientationBinningKernel : public ICLKernel
37{
38public:
39 /** Default constructor */
40 CLHOGOrientationBinningKernel();
41 /** Prevent instances of this class from being copied (As this class contains pointers) */
42 CLHOGOrientationBinningKernel(const CLHOGOrientationBinningKernel &) = delete;
43 /** Prevent instances of this class from being copied (As this class contains pointers) */
44 CLHOGOrientationBinningKernel &operator=(const CLHOGOrientationBinningKernel &) = delete;
45 /** Allow instances of this class to be moved */
46 CLHOGOrientationBinningKernel(CLHOGOrientationBinningKernel &&) = default;
47 /** Allow instances of this class to be moved */
48 CLHOGOrientationBinningKernel &operator=(CLHOGOrientationBinningKernel &&) = default;
49 /** Default destructor */
50 ~CLHOGOrientationBinningKernel() = default;
51
52 /** Initialise the kernel's inputs, output and HOG's metadata
53 *
54 * @param[in] input_magnitude Input tensor which stores the magnitude of the gradient for each pixel. Data type supported: S16.
55 * @param[in] input_phase Input tensor which stores the phase of the gradient for each pixel. Data type supported: U8
56 * @param[out] output Output tensor which stores the local HOG for each cell. DataType supported: F32. Number of channels supported: equal to the number of histogram bins per cell
57 * @param[in] hog_info HOG's metadata
58 */
59 void configure(const ICLTensor *input_magnitude, const ICLTensor *input_phase, ICLTensor *output, const HOGInfo *hog_info);
60
61 // Inherited methods overridden:
62 void run(const Window &window, cl::CommandQueue &queue) override;
63
64private:
65 const ICLTensor *_input_magnitude;
66 const ICLTensor *_input_phase;
67 ICLTensor *_output;
68 Size2D _cell_size;
69};
70
71/** OpenCL kernel to perform HOG block normalization */
72class CLHOGBlockNormalizationKernel : public ICLKernel
73{
74public:
75 /** Default constructor */
76 CLHOGBlockNormalizationKernel();
77 /** Prevent instances of this class from being copied (As this class contains pointers) */
78 CLHOGBlockNormalizationKernel(const CLHOGBlockNormalizationKernel &) = delete;
79 /** Prevent instances of this class from being copied (As this class contains pointers) */
80 CLHOGBlockNormalizationKernel &operator=(const CLHOGBlockNormalizationKernel &) = delete;
81 /** Allow instances of this class to be moved */
82 CLHOGBlockNormalizationKernel(CLHOGBlockNormalizationKernel &&) = default;
83 /** Allow instances of this class to be moved */
84 CLHOGBlockNormalizationKernel &operator=(CLHOGBlockNormalizationKernel &&) = default;
85 /** Default destructor */
86 ~CLHOGBlockNormalizationKernel() = default;
87
88 /** Initialise the kernel's input, output and HOG's metadata
89 *
90 * @param[in] input Input tensor which stores the local HOG for each cell. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per cell
91 * @param[out] output Output tensor which stores the normalised blocks. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per block
92 * @param[in] hog_info HOG's metadata
93 */
94 void configure(const ICLTensor *input, ICLTensor *output, const HOGInfo *hog_info);
95
96 // Inherited methods overridden:
97 void run(const Window &window, cl::CommandQueue &queue) override;
98
99private:
100 const ICLTensor *_input;
101 ICLTensor *_output;
102 Size2D _num_cells_per_block_stride;
103};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +0100104} // namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100105#endif /* __ARM_COMPUTE_CLHOGDESCRIPTORKERNEL_H__ */