blob: 3cc472b2748d34134ac50281bdde812aeab4e548 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michalis Spyrouf4643372019-11-29 16:17:13 +00002 * 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_HOGINFO_H
25#define ARM_COMPUTE_HOGINFO_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/Size2D.h"
28#include "arm_compute/core/Types.h"
29
30#include <cstddef>
31
32namespace arm_compute
33{
34/** Store the HOG's metadata */
35class HOGInfo
36{
37public:
38 /** Default constructor */
39 HOGInfo();
40 /** Default destructor */
41 virtual ~HOGInfo() = default;
42 /** Allow instances of this class to be copy constructed */
43 HOGInfo(const HOGInfo &) = default;
44 /** Allow instances of this class to be copied */
45 HOGInfo &operator=(const HOGInfo &) = default;
46 /** Allow instances of this class to be move constructed */
47 HOGInfo(HOGInfo &&) = default;
48 /** Allow instances of this class to be moved */
49 HOGInfo &operator=(HOGInfo &&) = default;
50 /** Constructor
51 *
52 * @param[in] cell_size Cell size in pixels
53 * @param[in] block_size Block size in pixels. Must be a multiple of cell_size.
54 * @param[in] detection_window_size Detection window size in pixels. Must be a multiple of block_size and block_stride.
55 * @param[in] block_stride Distance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size
56 * @param[in] num_bins Number of histogram bins for each cell
57 * @param[in] normalization_type (Optional) Normalization type to use for each block
58 * @param[in] l2_hyst_threshold (Optional) Threshold used for L2HYS_NORM normalization method
59 * @param[in] phase_type (Optional) Type of @ref PhaseType
60 */
61 HOGInfo(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins,
62 HOGNormType normalization_type = HOGNormType::L2HYS_NORM, float l2_hyst_threshold = 0.2f, PhaseType phase_type = PhaseType::UNSIGNED);
63 /** Initialize the metadata structure with the given parameters
64 *
65 * @param[in] cell_size Cell size in pixels
66 * @param[in] block_size Block size in pixels. Must be a multiple of cell_size.
67 * @param[in] detection_window_size Detection window size in pixels. Must be a multiple of block_size and block_stride.
68 * @param[in] block_stride Distance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size
69 * @param[in] num_bins Number of histogram bins for each cell
70 * @param[in] normalization_type (Optional) Normalization type to use for each block
71 * @param[in] l2_hyst_threshold (Optional) Threshold used for L2HYS_NORM normalization method
72 * @param[in] phase_type (Optional) Type of @ref PhaseType
73 */
74 void init(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins,
75 HOGNormType normalization_type = HOGNormType::L2HYS_NORM, float l2_hyst_threshold = 0.2f, PhaseType phase_type = PhaseType::UNSIGNED);
76 /** The cell size in pixels
77 *
78 * @return The cell size in pixels
79 */
80 const Size2D &cell_size() const;
81 /** The block size in pixels
82 *
83 * @return The block size in pixels
84 */
85 const Size2D &block_size() const;
86 /** The detection window size in pixels
87 *
88 * @return The detection window size in pixels
89 */
90 const Size2D &detection_window_size() const;
91 /** The block stride in pixels. The block stride is the distance between 2 consecutive blocks
92 *
93 * @return The block stride in pixels
94 */
95 const Size2D &block_stride() const;
96 /** The number of histogram bins for each cell
97 *
98 * @return The number of histogram bins for each cell
99 */
100 size_t num_bins() const;
101 /** The normalization type
102 *
103 * @return The normalization type
104 */
105 HOGNormType normalization_type() const;
106 /** Threshold used for L2HYS_NORM normalization type
107 *
108 * @return Threshold used for L2HYS_NORM normalization type
109 */
110 float l2_hyst_threshold() const;
111 /** The type of @ref PhaseType
112 *
113 * @return The type of @ref PhaseType
114 */
115 PhaseType phase_type() const;
116 /** The size of HOG descriptor
117 *
118 * @return The size of HOG descriptor
119 */
120 size_t descriptor_size() const;
121 /** Calculates the number of cells for each block
122 *
123 * @return The Size2D data object which stores the number of cells along the x and y directions
124 */
125 Size2D num_cells_per_block() const;
John Richardson25f23682017-11-27 14:35:09 +0000126
127 /** Calculates the number of cells per block stride
128 *
129 * @return The Size2D data object which stores the number of cells per block stride along the x and y directions
130 */
131 Size2D num_cells_per_block_stride() const;
John Richardson684cb0f2018-01-09 11:17:00 +0000132 /** Calculates the number of block positions for the given image size
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100133 *
134 * @param[in] image_size The input image size data object
135 *
John Richardson684cb0f2018-01-09 11:17:00 +0000136 * @return The Size2D data object which stores the number of block positions along the x and y directions
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100137 */
John Richardson684cb0f2018-01-09 11:17:00 +0000138 Size2D num_block_positions_per_image(const Size2D &image_size) const;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100139
140private:
141 Size2D _cell_size;
142 Size2D _block_size;
143 Size2D _detection_window_size;
144 Size2D _block_stride;
145 size_t _num_bins;
146 HOGNormType _normalization_type;
147 float _l2_hyst_threshold;
148 PhaseType _phase_type;
149 size_t _descriptor_size;
150};
151}
Michalis Spyrouf4643372019-11-29 16:17:13 +0000152#endif /*ARM_COMPUTE_HOGINFO_H */