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