Compute Library
 19.08
HOGInfo Class Reference

Store the HOG's metadata. More...

#include <HOGInfo.h>

Public Member Functions

 HOGInfo ()
 Default constructor. More...
 
virtual ~HOGInfo ()=default
 Default destructor. More...
 
 HOGInfo (const HOGInfo &)=default
 Allow instances of this class to be copy constructed. More...
 
HOGInfooperator= (const HOGInfo &)=default
 Allow instances of this class to be copied. More...
 
 HOGInfo (HOGInfo &&)=default
 Allow instances of this class to be move constructed. More...
 
HOGInfooperator= (HOGInfo &&)=default
 Allow instances of this class to be moved. More...
 
 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)
 Constructor. More...
 
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)
 Initialize the metadata structure with the given parameters. More...
 
const Size2Dcell_size () const
 The cell size in pixels. More...
 
const Size2Dblock_size () const
 The block size in pixels. More...
 
const Size2Ddetection_window_size () const
 The detection window size in pixels. More...
 
const Size2Dblock_stride () const
 The block stride in pixels. More...
 
size_t num_bins () const
 The number of histogram bins for each cell. More...
 
HOGNormType normalization_type () const
 The normalization type. More...
 
float l2_hyst_threshold () const
 Threshold used for L2HYS_NORM normalization type. More...
 
PhaseType phase_type () const
 The type of PhaseType. More...
 
size_t descriptor_size () const
 The size of HOG descriptor. More...
 
Size2D num_cells_per_block () const
 Calculates the number of cells for each block. More...
 
Size2D num_cells_per_block_stride () const
 Calculates the number of cells per block stride. More...
 
Size2D num_block_positions_per_image (const Size2D &image_size) const
 Calculates the number of block positions for the given image size. More...
 

Detailed Description

Store the HOG's metadata.

Definition at line 35 of file HOGInfo.h.

Constructor & Destructor Documentation

◆ HOGInfo() [1/4]

HOGInfo ( )

Default constructor.

Definition at line 31 of file HOGInfo.cpp.

32  : _cell_size(), _block_size(), _detection_window_size(), _block_stride(), _num_bins(0), _normalization_type(HOGNormType::L2HYS_NORM), _l2_hyst_threshold(0.0f), _phase_type(PhaseType::UNSIGNED),
33  _descriptor_size(0)
34 {
35 }
L2-norm followed by clipping.
Angle range: [0, 180].

References arm_compute::L2HYS_NORM, and arm_compute::UNSIGNED.

◆ ~HOGInfo()

virtual ~HOGInfo ( )
virtualdefault

Default destructor.

◆ HOGInfo() [2/4]

HOGInfo ( const HOGInfo )
default

Allow instances of this class to be copy constructed.

◆ HOGInfo() [3/4]

HOGInfo ( HOGInfo &&  )
default

Allow instances of this class to be move constructed.

◆ HOGInfo() [4/4]

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 
)

Constructor.

Parameters
[in]cell_sizeCell size in pixels
[in]block_sizeBlock size in pixels. Must be a multiple of cell_size.
[in]detection_window_sizeDetection window size in pixels. Must be a multiple of block_size and block_stride.
[in]block_strideDistance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size
[in]num_binsNumber of histogram bins for each cell
[in]normalization_type(Optional) Normalization type to use for each block
[in]l2_hyst_threshold(Optional) Threshold used for L2HYS_NORM normalization method
[in]phase_type(Optional) Type of PhaseType

Definition at line 37 of file HOGInfo.cpp.

39  : HOGInfo()
40 {
42 }
size_t num_bins() const
The number of histogram bins for each cell.
Definition: HOGInfo.cpp:111
const Size2D & detection_window_size() const
The detection window size in pixels.
Definition: HOGInfo.cpp:101
const Size2D & cell_size() const
The cell size in pixels.
Definition: HOGInfo.cpp:91
PhaseType phase_type() const
The type of PhaseType.
Definition: HOGInfo.cpp:126
const Size2D & block_stride() const
The block stride in pixels.
Definition: HOGInfo.cpp:106
HOGNormType normalization_type() const
The normalization type.
Definition: HOGInfo.cpp:116
HOGInfo()
Default constructor.
Definition: HOGInfo.cpp:31
const Size2D & block_size() const
The block size in pixels.
Definition: HOGInfo.cpp:96
float l2_hyst_threshold() const
Threshold used for L2HYS_NORM normalization type.
Definition: HOGInfo.cpp:121
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)
Initialize the metadata structure with the given parameters.
Definition: HOGInfo.cpp:44

References HOGInfo::block_size(), HOGInfo::block_stride(), HOGInfo::cell_size(), HOGInfo::detection_window_size(), HOGInfo::init(), HOGInfo::l2_hyst_threshold(), HOGInfo::normalization_type(), HOGInfo::num_bins(), and HOGInfo::phase_type().

Member Function Documentation

◆ block_size()

◆ block_stride()

◆ cell_size()

◆ descriptor_size()

size_t descriptor_size ( ) const

The size of HOG descriptor.

Returns
The size of HOG descriptor

Definition at line 131 of file HOGInfo.cpp.

132 {
133  return _descriptor_size;
134 }

Referenced by NEHOGDetectorKernel::configure(), CLHOGDetectorKernel::configure(), arm_compute::test::validation::reference::hog_detector(), and HOG::init().

◆ detection_window_size()

const Size2D & detection_window_size ( ) const

The detection window size in pixels.

Returns
The detection window size in pixels

Definition at line 101 of file HOGInfo.cpp.

102 {
103  return _detection_window_size;
104 }

Referenced by NEHOGDetectorKernel::configure(), CLHOGDetectorKernel::configure(), arm_compute::test::validation::reference::hog_detector(), HOGInfo::HOGInfo(), HOGInfo::init(), and arm_compute::operator<<().

◆ init()

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 
)

Initialize the metadata structure with the given parameters.

Parameters
[in]cell_sizeCell size in pixels
[in]block_sizeBlock size in pixels. Must be a multiple of cell_size.
[in]detection_window_sizeDetection window size in pixels. Must be a multiple of block_size and block_stride.
[in]block_strideDistance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size
[in]num_binsNumber of histogram bins for each cell
[in]normalization_type(Optional) Normalization type to use for each block
[in]l2_hyst_threshold(Optional) Threshold used for L2HYS_NORM normalization method
[in]phase_type(Optional) Type of PhaseType

Definition at line 44 of file HOGInfo.cpp.

46 {
47  ARM_COMPUTE_ERROR_ON_MSG((block_size.width % cell_size.width), "The block width must be multiple of cell width");
48  ARM_COMPUTE_ERROR_ON_MSG((block_size.height % cell_size.height), "Block height must be multiple of cell height");
49  ARM_COMPUTE_ERROR_ON_MSG((block_stride.width % cell_size.width), "Block stride width must be multiple of cell width");
50  ARM_COMPUTE_ERROR_ON_MSG((block_stride.height % cell_size.height), "Block stride height must be multiple of cell height");
51  ARM_COMPUTE_ERROR_ON_MSG(((detection_window_size.width - block_size.width) % block_stride.width), "Window width must be multiple of block width and block stride width");
52  ARM_COMPUTE_ERROR_ON_MSG(((detection_window_size.height - block_size.height) % block_stride.height), "Window height must be multiple of block height and block stride height");
53 
54  _cell_size = cell_size;
55  _block_size = block_size;
56  _detection_window_size = detection_window_size;
57  _block_stride = block_stride;
58  _num_bins = num_bins;
59  _normalization_type = normalization_type;
60  _l2_hyst_threshold = l2_hyst_threshold;
61  _phase_type = phase_type;
62 
63  // Compute descriptor size. +1 takes into account of the bias
64  _descriptor_size = num_cells_per_block().area() * num_block_positions_per_image(_detection_window_size).area() * _num_bins + 1;
65 }
size_t num_bins() const
The number of histogram bins for each cell.
Definition: HOGInfo.cpp:111
const Size2D & detection_window_size() const
The detection window size in pixels.
Definition: HOGInfo.cpp:101
const Size2D & cell_size() const
The cell size in pixels.
Definition: HOGInfo.cpp:91
PhaseType phase_type() const
The type of PhaseType.
Definition: HOGInfo.cpp:126
const Size2D & block_stride() const
The block stride in pixels.
Definition: HOGInfo.cpp:106
HOGNormType normalization_type() const
The normalization type.
Definition: HOGInfo.cpp:116
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
Size2D num_cells_per_block() const
Calculates the number of cells for each block.
Definition: HOGInfo.cpp:67
const Size2D & block_size() const
The block size in pixels.
Definition: HOGInfo.cpp:96
float l2_hyst_threshold() const
Threshold used for L2HYS_NORM normalization type.
Definition: HOGInfo.cpp:121
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Size2D num_block_positions_per_image(const Size2D &image_size) const
Calculates the number of block positions for the given image size.
Definition: HOGInfo.cpp:83
size_t area() const
The area of the image or rectangle calculated as (width * height)
Definition: Size2D.h:53
#define ARM_COMPUTE_ERROR_ON_MSG(cond,...)
Definition: Error.h:328

References Size2D::area(), ARM_COMPUTE_ERROR_ON_MSG, HOGInfo::block_size(), HOGInfo::block_stride(), HOGInfo::cell_size(), HOGInfo::detection_window_size(), Size2D::height, HOGInfo::l2_hyst_threshold(), HOGInfo::normalization_type(), HOGInfo::num_bins(), HOGInfo::num_block_positions_per_image(), HOGInfo::num_cells_per_block(), HOGInfo::phase_type(), and Size2D::width.

Referenced by HOGInfo::HOGInfo().

◆ l2_hyst_threshold()

float l2_hyst_threshold ( ) const

Threshold used for L2HYS_NORM normalization type.

Returns
Threshold used for L2HYS_NORM normalization type

Definition at line 121 of file HOGInfo.cpp.

122 {
123  return _l2_hyst_threshold;
124 }

Referenced by CLHOGBlockNormalizationKernel::configure(), NEHOGBlockNormalizationKernel::configure(), arm_compute::error_on_invalid_multi_hog(), HOGInfo::HOGInfo(), HOGInfo::init(), and arm_compute::operator<<().

◆ normalization_type()

HOGNormType normalization_type ( ) const

The normalization type.

Returns
The normalization type

Definition at line 116 of file HOGInfo.cpp.

117 {
118  return _normalization_type;
119 }

Referenced by CLHOGBlockNormalizationKernel::configure(), NEHOGBlockNormalizationKernel::configure(), arm_compute::error_on_invalid_multi_hog(), HOGInfo::HOGInfo(), HOGInfo::init(), and arm_compute::operator<<().

◆ num_bins()

◆ num_block_positions_per_image()

Size2D num_block_positions_per_image ( const Size2D image_size) const

Calculates the number of block positions for the given image size.

Parameters
[in]image_sizeThe input image size data object
Returns
The Size2D data object which stores the number of block positions along the x and y directions

Definition at line 83 of file HOGInfo.cpp.

84 {
85  ARM_COMPUTE_ERROR_ON(_block_stride.width == 0 || _block_stride.height == 0);
86 
87  return Size2D{ ((image_size.width - _block_size.width) / _block_stride.width) + 1,
88  ((image_size.height - _block_size.height) / _block_stride.height) + 1 };
89 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34

References ARM_COMPUTE_ERROR_ON, Size2D::height, and Size2D::width.

Referenced by arm_compute::test::validation::reference::hog_detector(), HOGInfo::init(), TensorInfo::init(), and TensorInfo::init_auto_padding().

◆ num_cells_per_block()

Size2D num_cells_per_block ( ) const

Calculates the number of cells for each block.

Returns
The Size2D data object which stores the number of cells along the x and y directions

Definition at line 67 of file HOGInfo.cpp.

68 {
69  ARM_COMPUTE_ERROR_ON(_cell_size.width == 0 || _cell_size.height == 0);
70 
71  return Size2D{ _block_size.width / _cell_size.width,
72  _block_size.height / _cell_size.height };
73 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34

References ARM_COMPUTE_ERROR_ON, Size2D::height, and Size2D::width.

Referenced by arm_compute::test::validation::reference::hog_block_normalization(), arm_compute::test::validation::reference::hog_detector(), HOGInfo::init(), TensorInfo::init(), and TensorInfo::init_auto_padding().

◆ num_cells_per_block_stride()

Size2D num_cells_per_block_stride ( ) const

Calculates the number of cells per block stride.

Returns
The Size2D data object which stores the number of cells per block stride along the x and y directions

Definition at line 75 of file HOGInfo.cpp.

76 {
77  ARM_COMPUTE_ERROR_ON(_cell_size.width == 0 || _cell_size.height == 0);
78 
79  return Size2D{ _block_stride.width / _cell_size.width,
80  _block_stride.height / _cell_size.height };
81 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34

References ARM_COMPUTE_ERROR_ON, Size2D::height, and Size2D::width.

Referenced by arm_compute::test::validation::reference::hog_block_normalization().

◆ operator=() [1/2]

HOGInfo& operator= ( const HOGInfo )
default

Allow instances of this class to be copied.

◆ operator=() [2/2]

HOGInfo& operator= ( HOGInfo &&  )
default

Allow instances of this class to be moved.

◆ phase_type()


The documentation for this class was generated from the following files: