Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
shot.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010-2011, Willow Garage, Inc.
6 * Copyright (c) 2012-, Open Perception, Inc.
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
12 * are met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 * * Neither the name of the copyright holder(s) nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 *
38 */
39
40#pragma once
41
42#include <pcl/point_types.h>
43#include <pcl/features/feature.h>
44
45#include <array> // for sRGB_LUT, sXYZ_LUT
46
47namespace pcl
48{
49 /** \brief SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for
50 * a given point cloud dataset containing points and normals.
51 *
52 * The suggested PointOutT is pcl::SHOT352.
53 *
54 * \note If you use this code in any academic work, please cite:
55 *
56 * - F. Tombari, S. Salti, L. Di Stefano
57 * Unique Signatures of Histograms for Local Surface Description.
58 * In Proceedings of the 11th European Conference on Computer Vision (ECCV),
59 * Heraklion, Greece, September 5-11 2010.
60 * - F. Tombari, S. Salti, L. Di Stefano
61 * A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
62 * In Proceedings of the 18th International Conference on Image Processing (ICIP),
63 * Brussels, Belgium, September 11-14 2011.
64 *
65 * \author Samuele Salti, Federico Tombari
66 * \ingroup features
67 */
68 template <typename PointInT, typename PointNT, typename PointOutT, typename PointRFT = pcl::ReferenceFrame>
69 class SHOTEstimationBase : public FeatureFromNormals<PointInT, PointNT, PointOutT>,
70 public FeatureWithLocalReferenceFrames<PointInT, PointRFT>
71 {
72 public:
86
88
89 protected:
90 /** \brief Empty constructor.
91 * \param[in] nr_shape_bins the number of bins in the shape histogram
92 */
95 lrf_radius_ (0),
96 sqradius_ (0), radius3_4_ (0), radius1_4_ (0), radius1_2_ (0),
97 nr_grid_sector_ (32),
99 descLength_ (0)
100 {
101 feature_name_ = "SHOTEstimation";
102 };
103
104 public:
105
106 /** \brief Empty destructor */
108
109 /** \brief Estimate the SHOT descriptor for a given point based on its spatial neighborhood of 3D points with normals
110 * \param[in] index the index of the point in indices_
111 * \param[in] indices the k-neighborhood point indices in surface_
112 * \param[in] sqr_dists the k-neighborhood point distances in surface_
113 * \param[out] shot the resultant SHOT descriptor representing the feature at the query point
114 */
115 virtual void
116 computePointSHOT (const int index,
117 const pcl::Indices &indices,
118 const std::vector<float> &sqr_dists,
119 Eigen::VectorXf &shot) = 0;
120
121 /** \brief Set the radius used for local reference frame estimation if the frames are not set by the user */
122 virtual void
123 setLRFRadius (float radius) { lrf_radius_ = radius; }
124
125 /** \brief Get the radius used for local reference frame estimation */
126 virtual float
127 getLRFRadius () const { return lrf_radius_; }
128
129 protected:
130
131 /** \brief This method should get called before starting the actual computation. */
132 bool
133 initCompute () override;
134
135 /** \brief Quadrilinear interpolation used when color and shape descriptions are NOT activated simultaneously
136 *
137 * \param[in] indices the neighborhood point indices
138 * \param[in] sqr_dists the neighborhood point distances
139 * \param[in] index the index of the point in indices_
140 * \param[out] binDistance the resultant distance shape histogram
141 * \param[in] nr_bins the number of bins in the shape histogram
142 * \param[out] shot the resultant SHOT histogram
143 */
144 void
146 const std::vector<float> &sqr_dists,
147 const int index,
148 std::vector<double> &binDistance,
149 const int nr_bins,
150 Eigen::VectorXf &shot);
151
152 /** \brief Normalize the SHOT histogram.
153 * \param[in,out] shot the SHOT histogram
154 * \param[in] desc_length the length of the histogram
155 */
156 void
157 normalizeHistogram (Eigen::VectorXf &shot, int desc_length);
158
159
160 /** \brief Create a binned distance shape histogram
161 * \param[in] index the index of the point in indices_
162 * \param[in] indices the k-neighborhood point indices in surface_
163 * \param[out] bin_distance_shape the resultant histogram
164 */
165 void
166 createBinDistanceShape (int index, const pcl::Indices &indices,
167 std::vector<double> &bin_distance_shape);
168
169 /** \brief The number of bins in each shape histogram. */
171
172 /** \brief Placeholder for a point's SHOT. */
173 Eigen::VectorXf shot_;
174
175 /** \brief The radius used for the LRF computation */
177
178 /** \brief The squared search radius. */
179 double sqradius_;
180
181 /** \brief 3/4 of the search radius. */
183
184 /** \brief 1/4 of the search radius. */
186
187 /** \brief 1/2 of the search radius. */
189
190 /** \brief Number of azimuthal sectors. */
192
193 /** \brief ... */
195
196 /** \brief One SHOT length. */
198 };
199
200 /** \brief SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for
201 * a given point cloud dataset containing points and normals.
202 *
203 * The suggested PointOutT is pcl::SHOT352
204 *
205 * \note If you use this code in any academic work, please cite:
206 *
207 * - F. Tombari, S. Salti, L. Di Stefano
208 * Unique Signatures of Histograms for Local Surface Description.
209 * In Proceedings of the 11th European Conference on Computer Vision (ECCV),
210 * Heraklion, Greece, September 5-11 2010.
211 * - F. Tombari, S. Salti, L. Di Stefano
212 * A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
213 * In Proceedings of the 18th International Conference on Image Processing (ICIP),
214 * Brussels, Belgium, September 11-14 2011.
215 *
216 * \author Samuele Salti, Federico Tombari
217 * \ingroup features
218 */
219 template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT352, typename PointRFT = pcl::ReferenceFrame>
220 class SHOTEstimation : public SHOTEstimationBase<PointInT, PointNT, PointOutT, PointRFT>
221 {
222 public:
245
247
248 /** \brief Empty constructor. */
250 {
251 feature_name_ = "SHOTEstimation";
252 };
253
254 /** \brief Empty destructor */
256
257 /** \brief Estimate the SHOT descriptor for a given point based on its spatial neighborhood of 3D points with normals
258 * \param[in] index the index of the point in indices_
259 * \param[in] indices the k-neighborhood point indices in surface_
260 * \param[in] sqr_dists the k-neighborhood point distances in surface_
261 * \param[out] shot the resultant SHOT descriptor representing the feature at the query point
262 */
263 void
264 computePointSHOT (const int index,
265 const pcl::Indices &indices,
266 const std::vector<float> &sqr_dists,
267 Eigen::VectorXf &shot) override;
268 protected:
269 /** \brief Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by
270 * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
271 * setSearchMethod ()
272 * \param output the resultant point cloud model dataset that contains the SHOT feature estimates
273 */
274 void
276 };
277
278 /** \brief SHOTColorEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given point cloud dataset
279 * containing points, normals and colors.
280 *
281 * The suggested PointOutT is pcl::SHOT1344
282 *
283 * \note If you use this code in any academic work, please cite:
284 *
285 * - F. Tombari, S. Salti, L. Di Stefano
286 * Unique Signatures of Histograms for Local Surface Description.
287 * In Proceedings of the 11th European Conference on Computer Vision (ECCV),
288 * Heraklion, Greece, September 5-11 2010.
289 * - F. Tombari, S. Salti, L. Di Stefano
290 * A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
291 * In Proceedings of the 18th International Conference on Image Processing (ICIP),
292 * Brussels, Belgium, September 11-14 2011.
293 *
294 * \author Samuele Salti, Federico Tombari
295 * \ingroup features
296 */
297 template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT1344, typename PointRFT = pcl::ReferenceFrame>
298 class SHOTColorEstimation : public SHOTEstimationBase<PointInT, PointNT, PointOutT, PointRFT>
299 {
300 public:
323
325
326 /** \brief Empty constructor.
327 * \param[in] describe_shape
328 * \param[in] describe_color
329 */
331 bool describe_color = true)
335 nr_color_bins_ (30)
336 {
337 feature_name_ = "SHOTColorEstimation";
338 };
339
340 /** \brief Empty destructor */
342
343 /** \brief Estimate the SHOT descriptor for a given point based on its spatial neighborhood of 3D points with normals
344 * \param[in] index the index of the point in indices_
345 * \param[in] indices the k-neighborhood point indices in surface_
346 * \param[in] sqr_dists the k-neighborhood point distances in surface_
347 * \param[out] shot the resultant SHOT descriptor representing the feature at the query point
348 */
349 void
350 computePointSHOT (const int index,
351 const pcl::Indices &indices,
352 const std::vector<float> &sqr_dists,
353 Eigen::VectorXf &shot) override;
354 protected:
355 /** \brief Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by
356 * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
357 * setSearchMethod ()
358 * \param output the resultant point cloud model dataset that contains the SHOT feature estimates
359 */
360 void
362
363 /** \brief Quadrilinear interpolation; used when color and shape descriptions are both activated
364 * \param[in] indices the neighborhood point indices
365 * \param[in] sqr_dists the neighborhood point distances
366 * \param[in] index the index of the point in indices_
367 * \param[out] binDistanceShape the resultant distance shape histogram
368 * \param[out] binDistanceColor the resultant color shape histogram
369 * \param[in] nr_bins_shape the number of bins in the shape histogram
370 * \param[in] nr_bins_color the number of bins in the color histogram
371 * \param[out] shot the resultant SHOT histogram
372 */
373 void
375 const std::vector<float> &sqr_dists,
376 const int index,
377 std::vector<double> &binDistanceShape,
378 std::vector<double> &binDistanceColor,
379 const int nr_bins_shape,
380 const int nr_bins_color,
381 Eigen::VectorXf &shot);
382
383 /** \brief Compute shape descriptor. */
385
386 /** \brief Compute color descriptor. */
388
389 /** \brief The number of bins in each color histogram. */
391
392 public:
393 /** \brief Converts RGB triplets to CIELab space.
394 * \param[in] R the red channel
395 * \param[in] G the green channel
396 * \param[in] B the blue channel
397 * \param[out] L the lightness
398 * \param[out] A the first color-opponent dimension
399 * \param[out] B2 the second color-opponent dimension
400 */
401 static void
402 RGB2CIELAB (unsigned char R, unsigned char G, unsigned char B, float &L, float &A, float &B2);
403
404 static std::array<float, 256> sRGB_LUT;
405 static std::array<float, 4000> sXYZ_LUT;
406 };
407}
408
409#ifdef PCL_NO_PRECOMPILE
410#include <pcl/features/impl/shot.hpp>
411#endif
Iterator class for point clouds with or without given indices.
PointCloudNConstPtr normals_
A pointer to the input dataset that contains the point normals of the XYZ dataset.
Definition feature.h:355
Feature represents the base feature class.
Definition feature.h:107
double search_parameter_
The actual search parameter (from either search_radius_ or k_).
Definition feature.h:237
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition feature.h:247
double search_radius_
The nearest neighbors search radius for each point.
Definition feature.h:240
int k_
The number of K nearest neighbors to use for each point.
Definition feature.h:243
std::string feature_name_
The feature name.
Definition feature.h:223
PointCloudInConstPtr surface_
An input point cloud describing the surface that is to be used for nearest neighbors estimation.
Definition feature.h:231
bool fake_surface_
If no surface is given, we use the input PointCloud as the surface.
Definition feature.h:258
FeatureWithLocalReferenceFrames provides a public interface for descriptor extractor classes which ne...
Definition feature.h:449
PointCloudLRFConstPtr frames_
A boost shared pointer to the local reference frames.
Definition feature.h:483
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
SHOTColorEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a giv...
Definition shot.h:299
static std::array< float, 4000 > sXYZ_LUT
Definition shot.h:405
bool b_describe_color_
Compute color descriptor.
Definition shot.h:387
typename Feature< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition shot.h:324
void interpolateDoubleChannel(const pcl::Indices &indices, const std::vector< float > &sqr_dists, const int index, std::vector< double > &binDistanceShape, std::vector< double > &binDistanceColor, const int nr_bins_shape, const int nr_bins_color, Eigen::VectorXf &shot)
Quadrilinear interpolation; used when color and shape descriptions are both activated.
Definition shot.hpp:412
SHOTColorEstimation(bool describe_shape=true, bool describe_color=true)
Empty constructor.
Definition shot.h:330
void computeFeature(pcl::PointCloud< PointOutT > &output) override
Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by ...
Definition shot.hpp:809
bool b_describe_shape_
Compute shape descriptor.
Definition shot.h:384
~SHOTColorEstimation()
Empty destructor.
Definition shot.h:341
int nr_color_bins_
The number of bins in each color histogram.
Definition shot.h:390
static std::array< float, 256 > sRGB_LUT
Definition shot.h:404
static void RGB2CIELAB(unsigned char R, unsigned char G, unsigned char B, float &L, float &A, float &B2)
Converts RGB triplets to CIELab space.
Definition shot.hpp:100
void computePointSHOT(const int index, const pcl::Indices &indices, const std::vector< float > &sqr_dists, Eigen::VectorXf &shot) override
Estimate the SHOT descriptor for a given point based on its spatial neighborhood of 3D points with no...
Definition shot.hpp:628
SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given po...
Definition shot.h:71
double radius1_2_
1/2 of the search radius.
Definition shot.h:188
typename Feature< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition shot.h:87
Eigen::VectorXf shot_
Placeholder for a point's SHOT.
Definition shot.h:173
virtual float getLRFRadius() const
Get the radius used for local reference frame estimation.
Definition shot.h:127
const int maxAngularSectors_
...
Definition shot.h:194
bool initCompute() override
This method should get called before starting the actual computation.
Definition shot.hpp:140
const int nr_grid_sector_
Number of azimuthal sectors.
Definition shot.h:191
void normalizeHistogram(Eigen::VectorXf &shot, int desc_length)
Normalize the SHOT histogram.
Definition shot.hpp:220
double radius3_4_
3/4 of the search radius.
Definition shot.h:182
~SHOTEstimationBase()
Empty destructor.
Definition shot.h:107
int descLength_
One SHOT length.
Definition shot.h:197
void interpolateSingleChannel(const pcl::Indices &indices, const std::vector< float > &sqr_dists, const int index, std::vector< double > &binDistance, const int nr_bins, Eigen::VectorXf &shot)
Quadrilinear interpolation used when color and shape descriptions are NOT activated simultaneously.
Definition shot.hpp:237
virtual void computePointSHOT(const int index, const pcl::Indices &indices, const std::vector< float > &sqr_dists, Eigen::VectorXf &shot)=0
Estimate the SHOT descriptor for a given point based on its spatial neighborhood of 3D points with no...
double sqradius_
The squared search radius.
Definition shot.h:179
float lrf_radius_
The radius used for the LRF computation.
Definition shot.h:176
void createBinDistanceShape(int index, const pcl::Indices &indices, std::vector< double > &bin_distance_shape)
Create a binned distance shape histogram.
Definition shot.hpp:176
virtual void setLRFRadius(float radius)
Set the radius used for local reference frame estimation if the frames are not set by the user.
Definition shot.h:123
int nr_shape_bins_
The number of bins in each shape histogram.
Definition shot.h:170
SHOTEstimationBase(int nr_shape_bins=10)
Empty constructor.
Definition shot.h:93
double radius1_4_
1/4 of the search radius.
Definition shot.h:185
SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given po...
Definition shot.h:221
~SHOTEstimation()
Empty destructor.
Definition shot.h:255
SHOTEstimation()
Empty constructor.
Definition shot.h:249
typename Feature< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition shot.h:246
void computeFeature(pcl::PointCloud< PointOutT > &output) override
Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by ...
Definition shot.hpp:743
void computePointSHOT(const int index, const pcl::Indices &indices, const std::vector< float > &sqr_dists, Eigen::VectorXf &shot) override
Estimate the SHOT descriptor for a given point based on its spatial neighborhood of 3D points with no...
Definition shot.hpp:713
Defines all the PCL implemented PointT point type structures.
@ B
Definition norms.h:54
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133