Point Cloud Library (PCL)
1.7.1
Main Page
Modules
Namespaces
Classes
people
include
pcl
people
hog.h
1
/*
2
* Software License Agreement (Simplified BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2013-, Open Perception, Inc.
6
* Copyright (c) 2012, Piotr Dollar & Ron Appel. [pdollar-at-caltech.edu]
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions are met:
12
*
13
* 1. Redistributions of source code must retain the above copyright notice, this
14
* list of conditions and the following disclaimer.
15
*
16
* 2. Redistributions in binary form must reproduce the above copyright notice,
17
* this list of conditions and the following disclaimer in the documentation
18
* and/or other materials provided with the distribution.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
*
31
* The views and conclusions contained in the software and documentation are those
32
* of the authors and should not be interpreted as representing official policies,
33
* either expressed or implied, of the FreeBSD Project.
34
*
35
* hog.h
36
* Created on: Nov 30, 2012
37
* Derived from Piotr Dollar's MATLAB Image&Video Toolbox Version 3.00.
38
* Non-SSE version of the code provided by Matteo Munaro, Stefano Ghidoni and Stefano Michieletto
39
*/
40
41
#ifndef PCL_PEOPLE_HOG_H_
42
#define PCL_PEOPLE_HOG_H_
43
44
#include <pcl/pcl_macros.h>
45
46
namespace
pcl
47
{
48
namespace
people
49
{
50
/** \brief @b HOG represents a class for computing the HOG descriptor described in
51
* Dalal, N. and Triggs, B., "Histograms of oriented gradients for human detection", CVPR 2005.
52
* \author Matteo Munaro, Stefano Ghidoni, Stefano Michieletto
53
* \ingroup people
54
*/
55
class
PCL_EXPORTS
HOG
56
{
57
public
:
58
59
/** \brief Constructor. */
60
HOG
();
61
62
/** \brief Destructor. */
63
virtual
~
HOG
();
64
65
/**
66
* \brief Compute gradient magnitude and orientation at each location (uses sse).
67
*
68
* \param[in] I Image as array of float.
69
* \param[in] h Image height.
70
* \param[in] w Image width.
71
* \param[in] d Image number of channels.
72
* \param[out] M Gradient magnitude for each image point.
73
* \param[out] O Gradient orientation for each image point.
74
*/
75
void
76
gradMag (
float
*I,
int
h,
int
w,
int
d,
float
*M,
float
*O )
const
;
77
78
/**
79
* \brief Compute n_orients gradient histograms per bin_size x bin_size block of pixels.
80
*
81
* \param[in] M Gradient magnitude for each image point.
82
* \param[in] O Gradient orientation for each image point.
83
* \param[in] h Image height.
84
* \param[in] w Image width.
85
* \param[in] bin_size Spatial bin size.
86
* \param[in] n_orients Number of orientation bins.
87
* \param[in] soft_bin If true, each pixel can contribute to multiple spatial bins (using bilinear interpolation).
88
* \param[out] H Gradient histograms.
89
*/
90
void
91
gradHist (
float
*M,
float
*O,
int
h,
int
w,
int
bin_size,
int
n_orients,
bool
soft_bin,
float
*H)
const
;
92
93
/**
94
* \brief Normalize histogram of gradients.
95
*
96
* \param[in] H Gradient histograms.
97
* \param[in] h Image height.
98
* \param[in] w Image width.
99
* \param[in] bin_size Spatial bin size.
100
* \param[in] n_orients Number of orientation bins.
101
* \param[in] clip Value at which to clip histogram bins.
102
* \param[out] G Normalized gradient histograms.
103
*/
104
void
105
normalization (
float
*H,
int
h,
int
w,
int
bin_size,
int
n_orients,
float
clip,
float
*G )
const
;
106
107
/**
108
* \brief Compute HOG descriptor.
109
*
110
* \param[in] I Image as array of float between 0 and 1.
111
* \param[in] h Image height.
112
* \param[in] w Image width.
113
* \param[in] n_channels Image number of channels.
114
* \param[in] bin_size Spatial bin size.
115
* \param[in] n_orients Number of orientation bins.
116
* \param[in] soft_bin If true, each pixel can contribute to multiple spatial bins (using bilinear interpolation).
117
* \param[out] descriptor HOG descriptor.
118
*/
119
void
120
compute (
float
*I,
int
h,
int
w,
int
n_channels,
int
bin_size,
int
n_orients,
bool
soft_bin,
float
*descriptor);
121
122
/**
123
* \brief Compute HOG descriptor with default parameters.
124
*
125
* \param[in] I Image as array of float between 0 and 1.
126
* \param[out] descriptor HOG descriptor.
127
*/
128
void
129
compute (
float
*I,
float
*descriptor)
const
;
130
131
private
:
132
133
/**
134
* \brief Compute x and y gradients for just one column (uses sse).
135
*/
136
void
137
grad1 (
float
*I,
float
*Gx,
float
*Gy,
int
h,
int
w,
int
x )
const
;
138
139
/**
140
* \brief Build lookup table a[] s.t. a[dx/2.02*n]~=acos(dx).
141
*/
142
float
*
143
acosTable ()
const
;
144
145
/**
146
* \brief Helper for gradHist, quantize O and M into O0, O1 and M0, M1 (uses sse).
147
*/
148
void
149
gradQuantize (
float
*O,
float
*M,
int
*O0,
int
*O1,
float
*M0,
float
*M1,
int
n_orients,
int
nb,
int
n,
float
norm )
const
;
150
151
/**
152
* \brief Platform independent aligned memory allocation (see also alFree).
153
*/
154
void
*
155
alMalloc (
size_t
size,
int
alignment )
const
;
156
157
/**
158
* \brief Platform independent aligned memory de-allocation (see also alMalloc).
159
*/
160
void
161
alFree (
void
* aligned)
const
;
162
163
protected
:
164
165
/** \brief image height (default = 128) */
166
int
h_
;
167
168
/** \brief image width (default = 64) */
169
int
w_
;
170
171
/** \brief image number of channels (default = 3) */
172
int
n_channels_
;
173
174
/** \brief spatial bin size (default = 8) */
175
int
bin_size_
;
176
177
/** \brief number of orientation bins (default = 9) */
178
int
n_orients_
;
179
180
/** \brief if true, each pixel can contribute to multiple spatial bins (using bilinear interpolation) (default = true) */
181
bool
soft_bin_
;
182
183
/** \brief value at which to clip histogram bins (default = 0.2) */
184
float
clip_
;
185
186
};
187
}
/* namespace people */
188
}
/* namespace pcl */
189
#endif
/* PCL_PEOPLE_HOG_H_ */