aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/HOGInfo.h
blob: 3cc472b2748d34134ac50281bdde812aeab4e548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (c) 2016-2019 ARM Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
#ifndef ARM_COMPUTE_HOGINFO_H
#define ARM_COMPUTE_HOGINFO_H

#include "arm_compute/core/Size2D.h"
#include "arm_compute/core/Types.h"

#include <cstddef>

namespace arm_compute
{
/** Store the HOG's metadata */
class HOGInfo
{
public:
    /** Default constructor */
    HOGInfo();
    /** Default destructor */
    virtual ~HOGInfo() = default;
    /** Allow instances of this class to be copy constructed */
    HOGInfo(const HOGInfo &) = default;
    /** Allow instances of this class to be copied */
    HOGInfo &operator=(const HOGInfo &) = default;
    /** Allow instances of this class to be move constructed */
    HOGInfo(HOGInfo &&) = default;
    /** Allow instances of this class to be moved */
    HOGInfo &operator=(HOGInfo &&) = default;
    /** Constructor
     *
     * @param[in] cell_size             Cell size in pixels
     * @param[in] block_size            Block size in pixels. Must be a multiple of cell_size.
     * @param[in] detection_window_size Detection window size in pixels. Must be a multiple of block_size and block_stride.
     * @param[in] block_stride          Distance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size
     * @param[in] num_bins              Number of histogram bins for each cell
     * @param[in] normalization_type    (Optional) Normalization type to use for each block
     * @param[in] l2_hyst_threshold     (Optional) Threshold used for L2HYS_NORM normalization method
     * @param[in] phase_type            (Optional) Type of @ref PhaseType
     */
    HOGInfo(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins,
            HOGNormType normalization_type = HOGNormType::L2HYS_NORM, float l2_hyst_threshold = 0.2f, PhaseType phase_type = PhaseType::UNSIGNED);
    /** Initialize the metadata structure with the given parameters
     *
     * @param[in] cell_size             Cell size in pixels
     * @param[in] block_size            Block size in pixels. Must be a multiple of cell_size.
     * @param[in] detection_window_size Detection window size in pixels. Must be a multiple of block_size and block_stride.
     * @param[in] block_stride          Distance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size
     * @param[in] num_bins              Number of histogram bins for each cell
     * @param[in] normalization_type    (Optional) Normalization type to use for each block
     * @param[in] l2_hyst_threshold     (Optional) Threshold used for L2HYS_NORM normalization method
     * @param[in] phase_type            (Optional) Type of @ref PhaseType
     */
    void init(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins,
              HOGNormType normalization_type = HOGNormType::L2HYS_NORM, float l2_hyst_threshold = 0.2f, PhaseType phase_type = PhaseType::UNSIGNED);
    /** The cell size in pixels
     *
     * @return The cell size in pixels
     */
    const Size2D &cell_size() const;
    /** The block size in pixels
     *
     * @return The block size in pixels
     */
    const Size2D &block_size() const;
    /** The detection window size in pixels
     *
     * @return The detection window size in pixels
     */
    const Size2D &detection_window_size() const;
    /** The block stride in pixels. The block stride is the distance between 2 consecutive blocks
     *
     * @return The block stride in pixels
     */
    const Size2D &block_stride() const;
    /** The number of histogram bins for each cell
     *
     * @return The number of histogram bins for each cell
     */
    size_t num_bins() const;
    /** The normalization type
     *
     * @return The normalization type
     */
    HOGNormType normalization_type() const;
    /** Threshold used for L2HYS_NORM normalization type
     *
     * @return Threshold used for L2HYS_NORM normalization type
     */
    float l2_hyst_threshold() const;
    /** The type of @ref PhaseType
     *
     * @return The type of @ref PhaseType
     */
    PhaseType phase_type() const;
    /** The size of HOG descriptor
     *
     * @return The size of HOG descriptor
     */
    size_t descriptor_size() const;
    /** Calculates the number of cells for each block
     *
     * @return The Size2D data object which stores the number of cells along the x and y directions
     */
    Size2D num_cells_per_block() const;

    /** Calculates the number of cells per block stride
     *
     * @return The Size2D data object which stores the number of cells per block stride along the x and y directions
     */
    Size2D num_cells_per_block_stride() const;
    /** Calculates the number of block positions for the given image size
     *
     * @param[in] image_size The input image size data object
     *
     * @return The Size2D data object which stores the number of block positions along the x and y directions
     */
    Size2D num_block_positions_per_image(const Size2D &image_size) const;

private:
    Size2D      _cell_size;
    Size2D      _block_size;
    Size2D      _detection_window_size;
    Size2D      _block_stride;
    size_t      _num_bins;
    HOGNormType _normalization_type;
    float       _l2_hyst_threshold;
    PhaseType   _phase_type;
    size_t      _descriptor_size;
};
}
#endif /*ARM_COMPUTE_HOGINFO_H */