Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
organized_multi_plane_segmentation.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-2012, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id: organized_multi_plane_segmentation.h 5494 2012-04-04 02:12:25Z rusu $
37  *
38  */
39 
40 #ifndef PCL_SEGMENTATION_ORGANIZED_MULTI_PLANE_SEGMENTATION_H_
41 #define PCL_SEGMENTATION_ORGANIZED_MULTI_PLANE_SEGMENTATION_H_
42 
44 #include <pcl/pcl_base.h>
45 #include <pcl/common/angles.h>
46 #include <pcl/PointIndices.h>
47 #include <pcl/ModelCoefficients.h>
50 
51 namespace pcl
52 {
61  template<typename PointT, typename PointNT, typename PointLT>
63  {
68 
69  public:
71  typedef typename PointCloud::Ptr PointCloudPtr;
73 
75  typedef typename PointCloudN::Ptr PointCloudNPtr;
77 
79  typedef typename PointCloudL::Ptr PointCloudLPtr;
81 
85 
89 
92  normals_ (),
93  min_inliers_ (1000),
94  angular_threshold_ (pcl::deg2rad (3.0)),
95  distance_threshold_ (0.02),
96  maximum_curvature_ (0.001),
97  project_points_ (false),
98  compare_ (new PlaneComparator ()), refinement_compare_ (new PlaneRefinementComparator ())
99  {
100  }
101 
103  virtual
105  {
106  }
107 
111  inline void
113  {
114  normals_ = normals;
115  }
116 
118  inline PointCloudNConstPtr
120  {
121  return (normals_);
122  }
123 
127  inline void
128  setMinInliers (unsigned min_inliers)
129  {
130  min_inliers_ = min_inliers;
131  }
132 
134  inline unsigned
135  getMinInliers () const
136  {
137  return (min_inliers_);
138  }
139 
143  inline void
144  setAngularThreshold (double angular_threshold)
145  {
146  angular_threshold_ = angular_threshold;
147  }
148 
150  inline double
152  {
153  return (angular_threshold_);
154  }
155 
159  inline void
160  setDistanceThreshold (double distance_threshold)
161  {
162  distance_threshold_ = distance_threshold;
163  }
164 
166  inline double
168  {
169  return (distance_threshold_);
170  }
171 
175  inline void
176  setMaximumCurvature (double maximum_curvature)
177  {
178  maximum_curvature_ = maximum_curvature;
179  }
180 
182  inline double
184  {
185  return (maximum_curvature_);
186  }
187 
191  void
193  {
194  compare_ = compare;
195  }
196 
200  void
202  {
203  refinement_compare_ = compare;
204  }
205 
209  void
210  setProjectPoints (bool project_points)
211  {
212  project_points_ = project_points;
213  }
214 
223  void
224  segment (std::vector<ModelCoefficients>& model_coefficients,
225  std::vector<PointIndices>& inlier_indices,
226  std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >& centroids,
227  std::vector <Eigen::Matrix3f, Eigen::aligned_allocator<Eigen::Matrix3f> >& covariances,
228  pcl::PointCloud<PointLT>& labels,
229  std::vector<pcl::PointIndices>& label_indices);
230 
235  void
236  segment (std::vector<ModelCoefficients>& model_coefficients,
237  std::vector<PointIndices>& inlier_indices);
238 
242  void
243  segment (std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT> > >& regions);
244 
248  void
249  segmentAndRefine (std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT> > >& regions);
250 
260  void
261  segmentAndRefine (std::vector<PlanarRegion<PointT>, Eigen::aligned_allocator<PlanarRegion<PointT> > >& regions,
262  std::vector<ModelCoefficients>& model_coefficients,
263  std::vector<PointIndices>& inlier_indices,
264  PointCloudLPtr& labels,
265  std::vector<pcl::PointIndices>& label_indices,
266  std::vector<pcl::PointIndices>& boundary_indices);
267 
276  void
277  refine (std::vector<ModelCoefficients>& model_coefficients,
278  std::vector<PointIndices>& inlier_indices,
279  std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >& centroids,
280  std::vector <Eigen::Matrix3f, Eigen::aligned_allocator<Eigen::Matrix3f> >& covariances,
281  PointCloudLPtr& labels,
282  std::vector<pcl::PointIndices>& label_indices);
283 
284  protected:
285 
287  PointCloudNConstPtr normals_;
288 
290  unsigned min_inliers_;
291 
293  double angular_threshold_;
294 
296  double distance_threshold_;
297 
299  double maximum_curvature_;
300 
302  bool project_points_;
303 
305  PlaneComparatorPtr compare_;
306 
308  PlaneRefinementComparatorPtr refinement_compare_;
309 
311  virtual std::string
312  getClassName () const
313  {
314  return ("OrganizedMultiPlaneSegmentation");
315  }
316  };
317 
318 }
319 
320 #endif //#ifndef PCL_SEGMENTATION_ORGANIZED_MULTI_PLANE_SEGMENTATION_H_