• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016-2019 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_HOGINFO_H
25 #define ARM_COMPUTE_HOGINFO_H
26 
27 #include "arm_compute/core/Size2D.h"
28 #include "arm_compute/core/Types.h"
29 
30 #include <cstddef>
31 
32 namespace arm_compute
33 {
34 /** Store the HOG's metadata */
35 class HOGInfo
36 {
37 public:
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;
126 
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;
132     /** Calculates the number of block positions for the given image size
133      *
134      * @param[in] image_size The input image size data object
135      *
136      * @return The Size2D data object which stores the number of block positions along the x and y directions
137      */
138     Size2D num_block_positions_per_image(const Size2D &image_size) const;
139 
140 private:
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 }
152 #endif /*ARM_COMPUTE_HOGINFO_H */
153