Point Cloud Library (PCL)  1.9.0-dev
grsd.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2014, Willow Garage, Inc.
6  * Copyright (c) 2014-, 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 #ifndef PCL_FEATURES_GRSD_H_
40 #define PCL_FEATURES_GRSD_H_
41 
42 #include <pcl/features/feature.h>
43 #include <pcl/features/rsd.h>
44 #include <pcl/filters/voxel_grid.h>
45 #include <pcl/kdtree/kdtree_flann.h>
46 
47 namespace pcl
48 {
49  /** \brief @b GRSDEstimation estimates the Global Radius-based Surface Descriptor (GRSD) for a given point cloud dataset
50  * containing points and normals.
51  *
52  * @note If you use this code in any academic work, please cite (first for the ray-casting and second for the additive version):
53  *
54  * <ul>
55  * <li> Z.C. Marton, D. Pangercic, N. Blodow, Michael Beetz.
56  * Combined 2D-3D Categorization and Classification for Multimodal Perception Systems.
57  * In The International Journal of Robotics Research, Sage Publications
58  * pages 1378--1402, Volume 30, Number 11, September 2011.
59  * </li>
60  * <li> A. Kanezaki, Z.C. Marton, D. Pangercic, T. Harada, Y. Kuniyoshi, M. Beetz.
61  * Voxelized Shape and Color Histograms for RGB-D
62  * In the Workshop on Active Semantic Perception and Object Search in the Real World, in conjunction with the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)
63  * San Francisco, California, September 25-30, 2011.
64  * </li>
65  * </ul>
66  *
67  * @note The code is stateful as we do not expect this class to be multicore parallelized. Please look at
68  * \ref FPFHEstimationOMP for examples on parallel implementations of the FPFH (Fast Point Feature Histogram).
69  * \author Zoltan Csaba Marton
70  * \ingroup features
71  */
72 
73  template <typename PointInT, typename PointNT, typename PointOutT>
74  class GRSDEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
75  {
76  public:
85  //using Feature<PointInT, PointOutT>::computeFeature;
86 
90 
91  /** \brief Constructor. */
92  GRSDEstimation () : additive_ (true)
93  {
94  feature_name_ = "GRSDEstimation";
95  relative_coordinates_all_ = getAllNeighborCellIndices ();
96  };
97 
98  /** \brief Set the sphere radius that is to be used for determining the nearest neighbors used for the feature
99  * estimation. Same value will be used for the internal voxel grid leaf size.
100  * \param[in] radius the sphere radius used as the maximum distance to consider a point a neighbor
101  */
102  inline void
103  setRadiusSearch (double radius) { width_ = search_radius_ = radius; }
104 
105  /** \brief Get the sphere radius used for determining the neighbors.
106  * \return the sphere radius used as the maximum distance to consider a point a neighbor
107  */
108  inline double
109  getRadiusSearch () const { return (search_radius_); }
110 
111  /** \brief Get the type of the local surface based on the min and max radius computed.
112  * \return the integer that represents the type of the local surface with values as
113  * Plane (1), Cylinder (2), Noise or corner (0), Sphere (3) and Edge (4)
114  */
115  static inline int
116  getSimpleType (float min_radius, float max_radius,
117  double min_radius_plane = 0.100,
118  double max_radius_noise = 0.015,
119  double min_radius_cylinder = 0.175,
120  double max_min_radius_diff = 0.050);
121 
122  protected:
123 
124  /** \brief Estimate the Global Radius-based Surface Descriptor (GRSD) for a set of points given by
125  * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
126  * setSearchMethod ()
127  * \param output the resultant point cloud that contains the GRSD feature
128  */
129  void
130  computeFeature (PointCloudOut &output);
131 
132  private:
133 
134  /** \brief Defines if an additive feature is computed or ray-casting is used to get a more descriptive feature. */
135  bool additive_;
136 
137  /** \brief Defines the voxel size to be used. */
138  double width_;
139 
140  /** \brief Pre-computed the relative cell indices of all the 26 neighbors. */
141  Eigen::MatrixXi relative_coordinates_all_;
142 
143  };
144 
145 }
146 
147 #ifdef PCL_NO_PRECOMPILE
148 #include <pcl/features/impl/grsd.hpp>
149 #endif
150 
151 #endif /* PCL_FEATURES_GRSD_H_ */
GRSDEstimation()
Constructor.
Definition: grsd.h:92
std::string feature_name_
The feature name.
Definition: feature.h:222
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
static int getSimpleType(float min_radius, float max_radius, double min_radius_plane=0.100, double max_radius_noise=0.015, double min_radius_cylinder=0.175, double max_min_radius_diff=0.050)
Get the type of the local surface based on the min and max radius computed.
Definition: grsd.hpp:45
void computeFeature(PointCloudOut &output)
Estimate the Global Radius-based Surface Descriptor (GRSD) for a set of points given by <setInputClou...
Definition: grsd.hpp:65
GRSDEstimation estimates the Global Radius-based Surface Descriptor (GRSD) for a given point cloud da...
Definition: grsd.h:74
Feature< PointInT, PointOutT >::PointCloudInPtr PointCloudInPtr
Definition: grsd.h:89
double getRadiusSearch() const
Get the sphere radius used for determining the neighbors.
Definition: grsd.h:109
PointCloudIn::Ptr PointCloudInPtr
Definition: feature.h:120
void setRadiusSearch(double radius)
Set the sphere radius that is to be used for determining the nearest neighbors used for the feature e...
Definition: grsd.h:103
PointCloud represents the base class in PCL for storing collections of 3D points. ...
Feature< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition: grsd.h:88
Eigen::MatrixXi getAllNeighborCellIndices()
Get the relative cell indices of all the 26 neighbors.
Definition: voxel_grid.h:122
Feature represents the base feature class.
Definition: feature.h:105
double search_radius_
The nearest neighbors search radius for each point.
Definition: feature.h:239
Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: grsd.h:87