blob: dc9bba8f20cb3d48cc8c1447e8eaccbd149207b8 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-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_CLHOGDETECTORKERNEL_H
25#define ARM_COMPUTE_CLHOGDETECTORKERNEL_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/CL/ICLArray.h"
28#include "arm_compute/core/CL/ICLHOG.h"
29#include "arm_compute/core/CL/ICLKernel.h"
30#include "arm_compute/core/CL/OpenCL.h"
31
32namespace cl
33{
34class Buffer;
35}
36
37namespace arm_compute
38{
39class ICLTensor;
40
41/** OpenCL kernel to perform HOG detector kernel using linear SVM */
42class CLHOGDetectorKernel : public ICLKernel
43{
44public:
45 /** Default constructor */
46 CLHOGDetectorKernel();
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 CLHOGDetectorKernel(const CLHOGDetectorKernel &) = delete;
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 CLHOGDetectorKernel &operator=(const CLHOGDetectorKernel &) = delete;
51 /** Allow instances of this class to be moved */
52 CLHOGDetectorKernel(CLHOGDetectorKernel &&) = default;
53 /** Allow instances of this class to be moved */
54 CLHOGDetectorKernel &operator=(CLHOGDetectorKernel &&) = default;
55 /** Default destructor */
56 ~CLHOGDetectorKernel() = default;
57
58 /** Initialise the kernel's input, HOG data-object, detection window, the stride of the detection window, the threshold and index of the object to detect
59 *
60 * @param[in] input Input tensor which stores the HOG descriptor obtained with @ref CLHOGOrientationBinningKernel. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per block
61 * @param[in] hog HOG data object used by @ref CLHOGOrientationBinningKernel and @ref CLHOGBlockNormalizationKernel
62 * @param[out] detection_windows Array of @ref DetectionWindow. This array stores all the detected objects
63 * @param[in] num_detection_windows Number of detected objects
64 * @param[in] detection_window_stride Distance in pixels between 2 consecutive detection windows in x and y directions.
65 * It must be multiple of the hog->info()->block_stride()
66 * @param[in] threshold (Optional) Threshold for the distance between features and SVM classifying plane
67 * @param[in] idx_class (Optional) Index of the class used for evaluating which class the detection window belongs to
68 */
69 void configure(const ICLTensor *input, const ICLHOG *hog, ICLDetectionWindowArray *detection_windows, cl::Buffer *num_detection_windows, const Size2D &detection_window_stride, float threshold = 0.0f,
70 uint16_t idx_class = 0);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010071 /** Initialise the kernel's input, HOG data-object, detection window, the stride of the detection window, the threshold and index of the object to detect
72 *
73 * @param[in] compile_context The compile context to be used.
74 * @param[in] input Input tensor which stores the HOG descriptor obtained with @ref CLHOGOrientationBinningKernel. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per block
75 * @param[in] hog HOG data object used by @ref CLHOGOrientationBinningKernel and @ref CLHOGBlockNormalizationKernel
76 * @param[out] detection_windows Array of @ref DetectionWindow. This array stores all the detected objects
77 * @param[in] num_detection_windows Number of detected objects
78 * @param[in] detection_window_stride Distance in pixels between 2 consecutive detection windows in x and y directions.
79 * It must be multiple of the hog->info()->block_stride()
80 * @param[in] threshold (Optional) Threshold for the distance between features and SVM classifying plane
81 * @param[in] idx_class (Optional) Index of the class used for evaluating which class the detection window belongs to
82 */
Manuel Bottini679fc962020-04-21 16:08:53 +010083 void configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLHOG *hog, ICLDetectionWindowArray *detection_windows, cl::Buffer *num_detection_windows,
Manuel Bottini4c6bd512020-04-08 10:15:51 +010084 const Size2D &detection_window_stride, float threshold = 0.0f,
85 uint16_t idx_class = 0);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086
87 // Inherited methods overridden:
88 void run(const Window &window, cl::CommandQueue &queue);
89
90private:
91 const ICLTensor *_input;
92 ICLDetectionWindowArray *_detection_windows;
93 cl::Buffer *_num_detection_windows;
94};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +010095} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000096#endif /* ARM_COMPUTE_CLHOGDETECTORKERNEL_H */