Point Cloud Library (PCL)  1.7.2
mls.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2011, 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$
37  *
38  */
39 
40 #ifndef PCL_MLS_H_
41 #define PCL_MLS_H_
42 
43 // PCL includes
44 #include <pcl/pcl_base.h>
45 #include <pcl/search/pcl_search.h>
46 #include <pcl/common/common.h>
47 
48 #include <pcl/surface/boost.h>
49 #include <pcl/surface/eigen.h>
50 #include <pcl/surface/processing.h>
51 #include <map>
52 
53 namespace pcl
54 {
55  /** \brief MovingLeastSquares represent an implementation of the MLS (Moving Least Squares) algorithm
56  * for data smoothing and improved normal estimation. It also contains methods for upsampling the
57  * resulting cloud based on the parametric fit.
58  * Reference paper: "Computing and Rendering Point Set Surfaces" by Marc Alexa, Johannes Behr,
59  * Daniel Cohen-Or, Shachar Fleishman, David Levin and Claudio T. Silva
60  * www.sci.utah.edu/~shachar/Publications/crpss.pdf
61  * \author Zoltan Csaba Marton, Radu B. Rusu, Alexandru E. Ichim, Suat Gedikli
62  * \ingroup surface
63  */
64  template <typename PointInT, typename PointOutT>
65  class MovingLeastSquares: public CloudSurfaceProcessing<PointInT, PointOutT>
66  {
67  public:
68  typedef boost::shared_ptr<MovingLeastSquares<PointInT, PointOutT> > Ptr;
69  typedef boost::shared_ptr<const MovingLeastSquares<PointInT, PointOutT> > ConstPtr;
70 
76 
81 
85 
89 
90  typedef boost::function<int (int, double, std::vector<int> &, std::vector<float> &)> SearchMethod;
91 
93 
94  /** \brief Empty constructor. */
95  MovingLeastSquares () : CloudSurfaceProcessing<PointInT, PointOutT> (),
96  normals_ (),
97  distinct_cloud_ (),
98  search_method_ (),
99  tree_ (),
100  order_ (2),
101  polynomial_fit_ (true),
102  search_radius_ (0.0),
103  sqr_gauss_param_ (0.0),
104  compute_normals_ (false),
106  upsampling_radius_ (0.0),
107  upsampling_step_ (0.0),
109  mls_results_ (),
110  voxel_size_ (1.0),
112  nr_coeff_ (),
114  rng_alg_ (),
115  rng_uniform_distribution_ ()
116  {};
117 
118  /** \brief Empty destructor */
119  virtual ~MovingLeastSquares () {}
120 
121 
122  /** \brief Set whether the algorithm should also store the normals computed
123  * \note This is optional, but need a proper output cloud type
124  */
125  inline void
126  setComputeNormals (bool compute_normals) { compute_normals_ = compute_normals; }
127 
128  /** \brief Provide a pointer to the search object.
129  * \param[in] tree a pointer to the spatial search object.
130  */
131  inline void
133  {
134  tree_ = tree;
135  // Declare the search locator definition
136  int (KdTree::*radiusSearch)(int index, double radius, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances, unsigned int max_nn) const = &KdTree::radiusSearch;
137  search_method_ = boost::bind (radiusSearch, boost::ref (tree_), _1, _2, _3, _4, 0);
138  }
139 
140  /** \brief Get a pointer to the search method used. */
141  inline KdTreePtr
142  getSearchMethod () { return (tree_); }
143 
144  /** \brief Set the order of the polynomial to be fit.
145  * \param[in] order the order of the polynomial
146  */
147  inline void
148  setPolynomialOrder (int order) { order_ = order; }
149 
150  /** \brief Get the order of the polynomial to be fit. */
151  inline int
152  getPolynomialOrder () { return (order_); }
153 
154  /** \brief Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimation.
155  * \param[in] polynomial_fit set to true for polynomial fit
156  */
157  inline void
158  setPolynomialFit (bool polynomial_fit) { polynomial_fit_ = polynomial_fit; }
159 
160  /** \brief Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial). */
161  inline bool
163 
164  /** \brief Set the sphere radius that is to be used for determining the k-nearest neighbors used for fitting.
165  * \param[in] radius the sphere radius that is to contain all k-nearest neighbors
166  * \note Calling this method resets the squared Gaussian parameter to radius * radius !
167  */
168  inline void
170 
171  /** \brief Get the sphere radius used for determining the k-nearest neighbors. */
172  inline double
174 
175  /** \brief Set the parameter used for distance based weighting of neighbors (the square of the search radius works
176  * best in general).
177  * \param[in] sqr_gauss_param the squared Gaussian parameter
178  */
179  inline void
180  setSqrGaussParam (double sqr_gauss_param) { sqr_gauss_param_ = sqr_gauss_param; }
181 
182  /** \brief Get the parameter for distance based weighting of neighbors. */
183  inline double
184  getSqrGaussParam () const { return (sqr_gauss_param_); }
185 
186  /** \brief Set the upsampling method to be used
187  * \param method
188  * \note Options are: * NONE - no upsampling will be done, only the input points will be projected to their own
189  * MLS surfaces
190  * * DISTINCT_CLOUD - will project the points of the distinct cloud to the closest point on
191  * the MLS surface
192  * * SAMPLE_LOCAL_PLANE - the local plane of each input point will be sampled in a circular
193  * fashion using the \ref upsampling_radius_ and the \ref upsampling_step_
194  * parameters
195  * * RANDOM_UNIFORM_DENSITY - the local plane of each input point will be sampled using an
196  * uniform random distribution such that the density of points is
197  * constant throughout the cloud - given by the \ref desired_num_points_in_radius_
198  * parameter
199  * * VOXEL_GRID_DILATION - the input cloud will be inserted into a voxel grid with voxels of
200  * size \ref voxel_size_; this voxel grid will be dilated \ref dilation_iteration_num_
201  * times and the resulting points will be projected to the MLS surface
202  * of the closest point in the input cloud; the result is a point cloud
203  * with filled holes and a constant point density
204  */
205  inline void
207 
208  /** \brief Set the distinct cloud used for the DISTINCT_CLOUD upsampling method. */
209  inline void
210  setDistinctCloud (PointCloudInConstPtr distinct_cloud) { distinct_cloud_ = distinct_cloud; }
211 
212  /** \brief Get the distinct cloud used for the DISTINCT_CLOUD upsampling method. */
213  inline PointCloudInConstPtr
215 
216 
217  /** \brief Set the radius of the circle in the local point plane that will be sampled
218  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
219  * \param[in] radius the radius of the circle
220  */
221  inline void
222  setUpsamplingRadius (double radius) { upsampling_radius_ = radius; }
223 
224  /** \brief Get the radius of the circle in the local point plane that will be sampled
225  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
226  */
227  inline double
229 
230  /** \brief Set the step size for the local plane sampling
231  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
232  * \param[in] step_size the step size
233  */
234  inline void
235  setUpsamplingStepSize (double step_size) { upsampling_step_ = step_size; }
236 
237 
238  /** \brief Get the step size for the local plane sampling
239  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
240  */
241  inline double
243 
244  /** \brief Set the parameter that specifies the desired number of points within the search radius
245  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
246  * \param[in] desired_num_points_in_radius the desired number of points in the output cloud in a sphere of
247  * radius \ref search_radius_ around each point
248  */
249  inline void
250  setPointDensity (int desired_num_points_in_radius) { desired_num_points_in_radius_ = desired_num_points_in_radius; }
251 
252 
253  /** \brief Get the parameter that specifies the desired number of points within the search radius
254  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
255  */
256  inline int
258 
259  /** \brief Set the voxel size for the voxel grid
260  * \note Used only in the VOXEL_GRID_DILATION upsampling method
261  * \param[in] voxel_size the edge length of a cubic voxel in the voxel grid
262  */
263  inline void
264  setDilationVoxelSize (float voxel_size) { voxel_size_ = voxel_size; }
265 
266 
267  /** \brief Get the voxel size for the voxel grid
268  * \note Used only in the VOXEL_GRID_DILATION upsampling method
269  */
270  inline float
272 
273  /** \brief Set the number of dilation steps of the voxel grid
274  * \note Used only in the VOXEL_GRID_DILATION upsampling method
275  * \param[in] iterations the number of dilation iterations
276  */
277  inline void
278  setDilationIterations (int iterations) { dilation_iteration_num_ = iterations; }
279 
280  /** \brief Get the number of dilation steps of the voxel grid
281  * \note Used only in the VOXEL_GRID_DILATION upsampling method
282  */
283  inline int
285 
286  /** \brief Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
287  * \param[out] output the resultant reconstructed surface model
288  */
289  void
290  process (PointCloudOut &output);
291 
292 
293  /** \brief Get the set of indices with each point in output having the
294  * corresponding point in input */
295  inline PointIndicesPtr
297 
298  protected:
299  /** \brief The point cloud that will hold the estimated normals, if set. */
301 
302  /** \brief The distinct point cloud that will be projected to the MLS surface. */
304 
305  /** \brief The search method template for indices. */
307 
308  /** \brief A pointer to the spatial search object. */
310 
311  /** \brief The order of the polynomial to be fit. */
312  int order_;
313 
314  /** True if the surface and normal be approximated using a polynomial, false if tangent estimation is sufficient. */
316 
317  /** \brief The nearest neighbors search radius for each point. */
319 
320  /** \brief Parameter for distance based weighting of neighbors (search_radius_ * search_radius_ works fine) */
322 
323  /** \brief Parameter that specifies whether the normals should be computed for the input cloud or not */
325 
326  /** \brief Parameter that specifies the upsampling method to be used */
328 
329  /** \brief Radius of the circle in the local point plane that will be sampled
330  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
331  */
333 
334  /** \brief Step size for the local plane sampling
335  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
336  */
338 
339  /** \brief Parameter that specifies the desired number of points within the search radius
340  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
341  */
343 
344 
345  /** \brief Data structure used to store the results of the MLS fitting
346  * \note Used only in the case of VOXEL_GRID_DILATION or DISTINCT_CLOUD upsampling
347  */
348  struct MLSResult
349  {
350  MLSResult () : mean (), plane_normal (), u_axis (), v_axis (), c_vec (), num_neighbors (), curvature (), valid (false) {}
351 
352  MLSResult (const Eigen::Vector3d &a_mean,
353  const Eigen::Vector3d &a_plane_normal,
354  const Eigen::Vector3d &a_u,
355  const Eigen::Vector3d &a_v,
356  const Eigen::VectorXd a_c_vec,
357  const int a_num_neighbors,
358  const float &a_curvature);
359 
360  Eigen::Vector3d mean, plane_normal, u_axis, v_axis;
361  Eigen::VectorXd c_vec;
363  float curvature;
364  bool valid;
365  };
366 
367  /** \brief Stores the MLS result for each point in the input cloud
368  * \note Used only in the case of VOXEL_GRID_DILATION or DISTINCT_CLOUD upsampling
369  */
370  std::vector<MLSResult> mls_results_;
371 
372 
373  /** \brief A minimalistic implementation of a voxel grid, necessary for the point cloud upsampling
374  * \note Used only in the case of VOXEL_GRID_DILATION upsampling
375  */
377  {
378  public:
379  struct Leaf { Leaf () : valid (true) {} bool valid; };
380 
382  IndicesPtr &indices,
383  float voxel_size);
384 
385  void
386  dilate ();
387 
388  inline void
389  getIndexIn1D (const Eigen::Vector3i &index, uint64_t &index_1d) const
390  {
391  index_1d = index[0] * data_size_ * data_size_ +
392  index[1] * data_size_ + index[2];
393  }
394 
395  inline void
396  getIndexIn3D (uint64_t index_1d, Eigen::Vector3i& index_3d) const
397  {
398  index_3d[0] = static_cast<Eigen::Vector3i::Scalar> (index_1d / (data_size_ * data_size_));
399  index_1d -= index_3d[0] * data_size_ * data_size_;
400  index_3d[1] = static_cast<Eigen::Vector3i::Scalar> (index_1d / data_size_);
401  index_1d -= index_3d[1] * data_size_;
402  index_3d[2] = static_cast<Eigen::Vector3i::Scalar> (index_1d);
403  }
404 
405  inline void
406  getCellIndex (const Eigen::Vector3f &p, Eigen::Vector3i& index) const
407  {
408  for (int i = 0; i < 3; ++i)
409  index[i] = static_cast<Eigen::Vector3i::Scalar> ((p[i] - bounding_min_(i)) / voxel_size_);
410  }
411 
412  inline void
413  getPosition (const uint64_t &index_1d, Eigen::Vector3f &point) const
414  {
415  Eigen::Vector3i index_3d;
416  getIndexIn3D (index_1d, index_3d);
417  for (int i = 0; i < 3; ++i)
418  point[i] = static_cast<Eigen::Vector3f::Scalar> (index_3d[i]) * voxel_size_ + bounding_min_[i];
419  }
420 
421  typedef std::map<uint64_t, Leaf> HashMap;
423  Eigen::Vector4f bounding_min_, bounding_max_;
424  uint64_t data_size_;
425  float voxel_size_;
426  };
427 
428 
429  /** \brief Voxel size for the VOXEL_GRID_DILATION upsampling method */
430  float voxel_size_;
431 
432  /** \brief Number of dilation steps for the VOXEL_GRID_DILATION upsampling method */
434 
435  /** \brief Number of coefficients, to be computed from the requested order.*/
437 
438  /** \brief Collects for each point in output the corrseponding point in the input. */
440 
441  /** \brief Search for the closest nearest neighbors of a given point using a radius search
442  * \param[in] index the index of the query point
443  * \param[out] indices the resultant vector of indices representing the k-nearest neighbors
444  * \param[out] sqr_distances the resultant squared distances from the query point to the k-nearest neighbors
445  */
446  inline int
447  searchForNeighbors (int index, std::vector<int> &indices, std::vector<float> &sqr_distances) const
448  {
449  return (search_method_ (index, search_radius_, indices, sqr_distances));
450  }
451 
452  /** \brief Smooth a given point and its neighborghood using Moving Least Squares.
453  * \param[in] index the inex of the query point in the input cloud
454  * \param[in] nn_indices the set of nearest neighbors indices for pt
455  * \param[in] nn_sqr_dists the set of nearest neighbors squared distances for pt
456  * \param[out] projected_points the set of points projected points around the query point
457  * (in the case of upsampling method NONE, only the query point projected to its own fitted surface will be returned,
458  * in the case of the other upsampling methods, multiple points will be returned)
459  * \param[out] projected_points_normals the normals corresponding to the projected points
460  * \param[out] corresponding_input_indices the set of indices with each point in output having the corresponding point in input
461  * \param[out] mls_result stores the MLS result for each point in the input cloud
462  * (used only in the case of VOXEL_GRID_DILATION or DISTINCT_CLOUD upsampling)
463  */
464  void
465  computeMLSPointNormal (int index,
466  const std::vector<int> &nn_indices,
467  std::vector<float> &nn_sqr_dists,
468  PointCloudOut &projected_points,
469  NormalCloud &projected_points_normals,
470  PointIndices &corresponding_input_indices,
471  MLSResult &mls_result) const;
472 
473  /** \brief Fits a point (sample point) given in the local plane coordinates of an input point (query point) to
474  * the MLS surface of the input point
475  * \param[in] u_disp the u coordinate of the sample point in the local plane of the query point
476  * \param[in] v_disp the v coordinate of the sample point in the local plane of the query point
477  * \param[in] u_axis the axis corresponding to the u-coordinates of the local plane of the query point
478  * \param[in] v_axis the axis corresponding to the v-coordinates of the local plane of the query point
479  * \param[in] n_axis
480  * \param mean
481  * \param[in] curvature the curvature of the surface at the query point
482  * \param[in] c_vec the coefficients of the polynomial fit on the MLS surface of the query point
483  * \param[in] num_neighbors the number of neighbors of the query point in the input cloud
484  * \param[out] result_point the absolute 3D position of the resulting projected point
485  * \param[out] result_normal the normal of the resulting projected point
486  */
487  void
488  projectPointToMLSSurface (float &u_disp, float &v_disp,
489  Eigen::Vector3d &u_axis, Eigen::Vector3d &v_axis,
490  Eigen::Vector3d &n_axis,
491  Eigen::Vector3d &mean,
492  float &curvature,
493  Eigen::VectorXd &c_vec,
494  int num_neighbors,
495  PointOutT &result_point,
496  pcl::Normal &result_normal) const;
497 
498  void
499  copyMissingFields (const PointInT &point_in,
500  PointOutT &point_out) const;
501 
502  /** \brief Abstract surface reconstruction method.
503  * \param[out] output the result of the reconstruction
504  */
505  virtual void performProcessing (PointCloudOut &output);
506 
507  /** \brief Perform upsampling for the distinct-cloud and voxel-grid methods
508  * \param[out] output the result of the reconstruction
509  */
510  void performUpsampling (PointCloudOut &output);
511 
512  private:
513  /** \brief Boost-based random number generator algorithm. */
514  boost::mt19937 rng_alg_;
515 
516  /** \brief Random number generator using an uniform distribution of floats
517  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
518  */
519  boost::shared_ptr<boost::variate_generator<boost::mt19937&,
520  boost::uniform_real<float> >
521  > rng_uniform_distribution_;
522 
523  /** \brief Abstract class get name method. */
524  std::string getClassName () const { return ("MovingLeastSquares"); }
525 
526  public:
527  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
528  };
529 
530 #ifdef _OPENMP
531  /** \brief MovingLeastSquaresOMP is a parallelized version of MovingLeastSquares, using the OpenMP standard.
532  * \note Compared to MovingLeastSquares, an overhead is incurred in terms of runtime and memory usage.
533  * \note The upsampling methods DISTINCT_CLOUD and VOXEL_GRID_DILATION are not parallelized completely, i.e. parts of the algorithm run on a single thread only.
534  * \author Robert Huitl
535  * \ingroup surface
536  */
537  template <typename PointInT, typename PointOutT>
538  class MovingLeastSquaresOMP: public MovingLeastSquares<PointInT, PointOutT>
539  {
540  public:
541  typedef boost::shared_ptr<MovingLeastSquares<PointInT, PointOutT> > Ptr;
542  typedef boost::shared_ptr<const MovingLeastSquares<PointInT, PointOutT> > ConstPtr;
543 
546  using MovingLeastSquares<PointInT, PointOutT>::normals_;
547  using MovingLeastSquares<PointInT, PointOutT>::corresponding_input_indices_;
548  using MovingLeastSquares<PointInT, PointOutT>::nr_coeff_;
549  using MovingLeastSquares<PointInT, PointOutT>::order_;
550  using MovingLeastSquares<PointInT, PointOutT>::compute_normals_;
551  using MovingLeastSquares<PointInT, PointOutT>::upsample_method_;
552  using MovingLeastSquares<PointInT, PointOutT>::VOXEL_GRID_DILATION;
553  using MovingLeastSquares<PointInT, PointOutT>::DISTINCT_CLOUD;
554 
555  typedef pcl::PointCloud<pcl::Normal> NormalCloud;
556  typedef pcl::PointCloud<pcl::Normal>::Ptr NormalCloudPtr;
557 
558  typedef pcl::PointCloud<PointOutT> PointCloudOut;
559  typedef typename PointCloudOut::Ptr PointCloudOutPtr;
560  typedef typename PointCloudOut::ConstPtr PointCloudOutConstPtr;
561 
562  /** \brief Constructor for parallelized Moving Least Squares
563  * \param threads the maximum number of hardware threads to use (0 sets the value to 1)
564  */
565  MovingLeastSquaresOMP (unsigned int threads = 0) : threads_ (threads)
566  {
567 
568  }
569 
570  /** \brief Set the maximum number of threads to use
571  * \param threads the maximum number of hardware threads to use (0 sets the value to 1)
572  */
573  inline void
574  setNumberOfThreads (unsigned int threads = 0)
575  {
576  threads_ = threads;
577  }
578 
579  protected:
580  /** \brief Abstract surface reconstruction method.
581  * \param[out] output the result of the reconstruction
582  */
583  virtual void performProcessing (PointCloudOut &output);
584 
585  /** \brief The maximum number of threads the scheduler should use. */
586  unsigned int threads_;
587  };
588 #endif
589 }
590 
591 #ifdef PCL_NO_PRECOMPILE
592 #include <pcl/surface/impl/mls.hpp>
593 #endif
594 
595 #endif /* #ifndef PCL_MLS_H_ */
A point structure representing normal coordinates and the surface curvature estimate.
int nr_coeff_
Number of coefficients, to be computed from the requested order.
Definition: mls.h:436
double getSqrGaussParam() const
Get the parameter for distance based weighting of neighbors.
Definition: mls.h:184
pcl::PointCloud< pcl::Normal > NormalCloud
Definition: mls.h:79
PointCloudOut::Ptr PointCloudOutPtr
Definition: mls.h:83
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
NormalCloudPtr normals_
The point cloud that will hold the estimated normals, if set.
Definition: mls.h:300
void setDilationVoxelSize(float voxel_size)
Set the voxel size for the voxel grid.
Definition: mls.h:264
void setSearchRadius(double radius)
Set the sphere radius that is to be used for determining the k-nearest neighbors used for fitting...
Definition: mls.h:169
int getPolynomialOrder()
Get the order of the polynomial to be fit.
Definition: mls.h:152
PointCloudIn::Ptr PointCloudInPtr
Definition: mls.h:87
int dilation_iteration_num_
Number of dilation steps for the VOXEL_GRID_DILATION upsampling method.
Definition: mls.h:433
double getUpsamplingRadius()
Get the radius of the circle in the local point plane that will be sampled.
Definition: mls.h:228
void setUpsamplingMethod(UpsamplingMethod method)
Set the upsampling method to be used.
Definition: mls.h:206
virtual void performProcessing(PointCloudOut &output)
Abstract surface reconstruction method.
Definition: mls.hpp:466
boost::shared_ptr< MovingLeastSquares< PointInT, PointOutT > > Ptr
Definition: mls.h:68
boost::shared_ptr< std::vector< int > > IndicesPtr
Definition: pcl_base.h:60
pcl::search::Search< PointInT > KdTree
Definition: mls.h:77
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
PointIndicesPtr corresponding_input_indices_
Collects for each point in output the corrseponding point in the input.
Definition: mls.h:439
void setPolynomialOrder(int order)
Set the order of the polynomial to be fit.
Definition: mls.h:148
virtual int radiusSearch(const PointInT &point, double radius, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const =0
Search for all the nearest neighbors of the query point in a given radius.
MovingLeastSquares()
Empty constructor.
Definition: mls.h:95
MovingLeastSquares represent an implementation of the MLS (Moving Least Squares) algorithm for data s...
Definition: mls.h:65
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition: pcl_base.h:153
Eigen::Vector4f bounding_max_
Definition: mls.h:423
KdTreePtr getSearchMethod()
Get a pointer to the search method used.
Definition: mls.h:142
SearchMethod search_method_
The search method template for indices.
Definition: mls.h:306
bool polynomial_fit_
True if the surface and normal be approximated using a polynomial, false if tangent estimation is suf...
Definition: mls.h:315
Eigen::Vector3d v_axis
Definition: mls.h:360
CloudSurfaceProcessing represents the base class for algorithms that takes a point cloud as input and...
Definition: processing.h:57
pcl::PointCloud< PointInT > PointCloudIn
Definition: mls.h:86
boost::shared_ptr< PointIndices > PointIndicesPtr
Definition: pcl_base.h:75
void setUpsamplingRadius(double radius)
Set the radius of the circle in the local point plane that will be sampled.
Definition: mls.h:222
void projectPointToMLSSurface(float &u_disp, float &v_disp, Eigen::Vector3d &u_axis, Eigen::Vector3d &v_axis, Eigen::Vector3d &n_axis, Eigen::Vector3d &mean, float &curvature, Eigen::VectorXd &c_vec, int num_neighbors, PointOutT &result_point, pcl::Normal &result_normal) const
Fits a point (sample point) given in the local plane coordinates of an input point (query point) to t...
Definition: mls.hpp:409
boost::shared_ptr< const MovingLeastSquares< PointInT, PointOutT > > ConstPtr
Definition: mls.h:69
double getSearchRadius()
Get the sphere radius used for determining the k-nearest neighbors.
Definition: mls.h:173
Eigen::Vector4f bounding_min_
Definition: mls.h:423
std::vector< MLSResult > mls_results_
Stores the MLS result for each point in the input cloud.
Definition: mls.h:370
double getUpsamplingStepSize()
Get the step size for the local plane sampling.
Definition: mls.h:242
pcl::PointCloud< PointOutT > PointCloudOut
Definition: mls.h:82
PointCloudOut::ConstPtr PointCloudOutConstPtr
Definition: mls.h:84
double upsampling_radius_
Radius of the circle in the local point plane that will be sampled.
Definition: mls.h:332
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
void getIndexIn3D(uint64_t index_1d, Eigen::Vector3i &index_3d) const
Definition: mls.h:396
void computeMLSPointNormal(int index, const std::vector< int > &nn_indices, std::vector< float > &nn_sqr_dists, PointCloudOut &projected_points, NormalCloud &projected_points_normals, PointIndices &corresponding_input_indices, MLSResult &mls_result) const
Smooth a given point and its neighborghood using Moving Least Squares.
Definition: mls.hpp:165
PointCloudInConstPtr distinct_cloud_
The distinct point cloud that will be projected to the MLS surface.
Definition: mls.h:303
PCL base class.
Definition: pcl_base.h:68
pcl::search::Search< PointInT >::Ptr KdTreePtr
Definition: mls.h:78
void performUpsampling(PointCloudOut &output)
Perform upsampling for the distinct-cloud and voxel-grid methods.
Definition: mls.hpp:590
void setDistinctCloud(PointCloudInConstPtr distinct_cloud)
Set the distinct cloud used for the DISTINCT_CLOUD upsampling method.
Definition: mls.h:210
double search_radius_
The nearest neighbors search radius for each point.
Definition: mls.h:318
void setUpsamplingStepSize(double step_size)
Set the step size for the local plane sampling.
Definition: mls.h:235
void setPolynomialFit(bool polynomial_fit)
Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimati...
Definition: mls.h:158
double upsampling_step_
Step size for the local plane sampling.
Definition: mls.h:337
void process(PointCloudOut &output)
Base method for surface reconstruction for all points given in &lt;setInputCloud (), setIndices ()&gt; ...
Definition: mls.hpp:57
int getPointDensity()
Get the parameter that specifies the desired number of points within the search radius.
Definition: mls.h:257
void setSqrGaussParam(double sqr_gauss_param)
Set the parameter used for distance based weighting of neighbors (the square of the search radius wor...
Definition: mls.h:180
PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: mls.h:88
KdTreePtr tree_
A pointer to the spatial search object.
Definition: mls.h:309
int searchForNeighbors(int index, std::vector< int > &indices, std::vector< float > &sqr_distances) const
Search for the closest nearest neighbors of a given point using a radius search.
Definition: mls.h:447
boost::shared_ptr< ::pcl::PointIndices > PointIndicesPtr
Definition: PointIndices.h:26
A minimalistic implementation of a voxel grid, necessary for the point cloud upsampling.
Definition: mls.h:376
Eigen::Vector3d u_axis
Definition: mls.h:360
MLSVoxelGrid(PointCloudInConstPtr &cloud, IndicesPtr &indices, float voxel_size)
Definition: mls.hpp:714
void getIndexIn1D(const Eigen::Vector3i &index, uint64_t &index_1d) const
Definition: mls.h:389
PointIndicesPtr getCorrespondingIndices()
Get the set of indices with each point in output having the corresponding point in input...
Definition: mls.h:296
Eigen::Vector3d plane_normal
Definition: mls.h:360
int order_
The order of the polynomial to be fit.
Definition: mls.h:312
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
Definition: mls.h:132
bool getPolynomialFit()
Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial)...
Definition: mls.h:162
int getDilationIterations()
Get the number of dilation steps of the voxel grid.
Definition: mls.h:284
float voxel_size_
Voxel size for the VOXEL_GRID_DILATION upsampling method.
Definition: mls.h:430
bool compute_normals_
Parameter that specifies whether the normals should be computed for the input cloud or not...
Definition: mls.h:324
int desired_num_points_in_radius_
Parameter that specifies the desired number of points within the search radius.
Definition: mls.h:342
float getDilationVoxelSize()
Get the voxel size for the voxel grid.
Definition: mls.h:271
void setDilationIterations(int iterations)
Set the number of dilation steps of the voxel grid.
Definition: mls.h:278
void getPosition(const uint64_t &index_1d, Eigen::Vector3f &point) const
Definition: mls.h:413
boost::function< int(int, double, std::vector< int > &, std::vector< float > &)> SearchMethod
Definition: mls.h:90
PointCloudConstPtr input_
The input point cloud dataset.
Definition: pcl_base.h:150
void setPointDensity(int desired_num_points_in_radius)
Set the parameter that specifies the desired number of points within the search radius.
Definition: mls.h:250
void setComputeNormals(bool compute_normals)
Set whether the algorithm should also store the normals computed.
Definition: mls.h:126
UpsamplingMethod upsample_method_
Parameter that specifies the upsampling method to be used.
Definition: mls.h:327
virtual ~MovingLeastSquares()
Empty destructor.
Definition: mls.h:119
void getCellIndex(const Eigen::Vector3f &p, Eigen::Vector3i &index) const
Definition: mls.h:406
void copyMissingFields(const PointInT &point_in, PointOutT &point_out) const
Definition: mls.hpp:769
PointCloudInConstPtr getDistinctCloud()
Get the distinct cloud used for the DISTINCT_CLOUD upsampling method.
Definition: mls.h:214
pcl::PointCloud< pcl::Normal >::Ptr NormalCloudPtr
Definition: mls.h:80
Data structure used to store the results of the MLS fitting.
Definition: mls.h:348
double sqr_gauss_param_
Parameter for distance based weighting of neighbors (search_radius_ * search_radius_ works fine) ...
Definition: mls.h:321
std::map< uint64_t, Leaf > HashMap
Definition: mls.h:421