Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cvfh.h
Go to the documentation of this file.
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  * $Id: cvfh.h 6089 2012-07-02 18:38:08Z rusu $
38  *
39  */
40 
41 #ifndef PCL_FEATURES_CVFH_H_
42 #define PCL_FEATURES_CVFH_H_
43 
44 #include <pcl/features/feature.h>
45 #include <pcl/features/normal_3d.h>
46 #include <pcl/features/vfh.h>
47 #include <pcl/search/pcl_search.h>
48 #include <pcl/common/common.h>
49 
50 namespace pcl
51 {
64  template<typename PointInT, typename PointNT, typename PointOutT = pcl::VFHSignature308>
65  class CVFHEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
66  {
67  public:
75 
80 
83  vpx_ (0), vpy_ (0), vpz_ (0),
84  leaf_size_ (0.005f),
85  normalize_bins_ (false),
86  curv_threshold_ (0.03f),
87  cluster_tolerance_ (leaf_size_ * 3),
88  eps_angle_threshold_ (0.125f),
89  min_points_ (50),
90  radius_normals_ (leaf_size_ * 3),
91  centroids_dominant_orientations_ (),
92  dominant_normals_ ()
93  {
94  search_radius_ = 0;
95  k_ = 1;
96  feature_name_ = "CVFHEstimation";
97  }
98  ;
99 
106  void
107  filterNormalsWithHighCurvature (const pcl::PointCloud<PointNT> & cloud, std::vector<int> & indices_to_use, std::vector<int> &indices_out,
108  std::vector<int> &indices_in, float threshold);
109 
115  inline void
116  setViewPoint (float vpx, float vpy, float vpz)
117  {
118  vpx_ = vpx;
119  vpy_ = vpy;
120  vpz_ = vpz;
121  }
122 
126  inline void
127  setRadiusNormals (float radius_normals)
128  {
129  radius_normals_ = radius_normals;
130  }
131 
137  inline void
138  getViewPoint (float &vpx, float &vpy, float &vpz)
139  {
140  vpx = vpx_;
141  vpy = vpy_;
142  vpz = vpz_;
143  }
144 
148  inline void
149  getCentroidClusters (std::vector<Eigen::Vector3f> & centroids)
150  {
151  for (size_t i = 0; i < centroids_dominant_orientations_.size (); ++i)
152  centroids.push_back (centroids_dominant_orientations_[i]);
153  }
154 
158  inline void
159  getCentroidNormalClusters (std::vector<Eigen::Vector3f> & centroids)
160  {
161  for (size_t i = 0; i < dominant_normals_.size (); ++i)
162  centroids.push_back (dominant_normals_[i]);
163  }
164 
169  inline void
171  {
172  cluster_tolerance_ = d;
173  }
174 
178  inline void
180  {
181  eps_angle_threshold_ = d;
182  }
183 
187  inline void
189  {
190  curv_threshold_ = d;
191  }
192 
196  inline void
197  setMinPoints (size_t min)
198  {
199  min_points_ = min;
200  }
201 
205  inline void
206  setNormalizeBins (bool normalize)
207  {
208  normalize_bins_ = normalize;
209  }
210 
214  void
215  compute (PointCloudOut &output);
216 
217  private:
221  float vpx_, vpy_, vpz_;
222 
226  float leaf_size_;
227 
229  bool normalize_bins_;
230 
232  float curv_threshold_;
233 
235  float cluster_tolerance_;
236 
238  float eps_angle_threshold_;
239 
243  size_t min_points_;
244 
246  float radius_normals_;
247 
255  void
256  computeFeature (PointCloudOut &output);
257 
271  void
272  extractEuclideanClustersSmooth (const pcl::PointCloud<pcl::PointNormal> &cloud,
273  const pcl::PointCloud<pcl::PointNormal> &normals, float tolerance,
275  std::vector<pcl::PointIndices> &clusters, double eps_angle,
276  unsigned int min_pts_per_cluster = 1,
277  unsigned int max_pts_per_cluster = (std::numeric_limits<int>::max) ());
278 
279  protected:
281  std::vector<Eigen::Vector3f> centroids_dominant_orientations_;
283  std::vector<Eigen::Vector3f> dominant_normals_;
284 
285  private:
289  void
290  computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &) {}
291  };
292 
293 }
294 
295 #endif //#ifndef PCL_FEATURES_VFH_H_