Point Cloud Library (PCL)  1.9.1
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 #include <boost/function.hpp>
53 
54 namespace pcl
55 {
56 
57  /** \brief Data structure used to store the results of the MLS fitting */
58  struct MLSResult
59  {
61  {
62  NONE, /**< \brief Project to the mls plane. */
63  SIMPLE, /**< \brief Project along the mls plane normal to the polynomial surface. */
64  ORTHOGONAL /**< \brief Project to the closest point on the polynonomial surface. */
65  };
66 
67  /** \brief Data structure used to store the MLS polynomial partial derivatives */
69  {
70  double z; /**< \brief The z component of the polynomial evaluated at z(u, v). */
71  double z_u; /**< \brief The partial derivative dz/du. */
72  double z_v; /**< \brief The partial derivative dz/dv. */
73  double z_uu; /**< \brief The partial derivative d^2z/du^2. */
74  double z_vv; /**< \brief The partial derivative d^2z/dv^2. */
75  double z_uv; /**< \brief The partial derivative d^2z/dudv. */
76  };
77 
78  /** \brief Data structure used to store the MLS projection results */
80  {
81  MLSProjectionResults () : u (0), v (0) {}
82 
83  double u; /**< \brief The u-coordinate of the projected point in local MLS frame. */
84  double v; /**< \brief The u-coordinate of the projected point in local MLS frame. */
85  Eigen::Vector3d point; /**< \brief The projected point. */
86  Eigen::Vector3d normal; /**< \brief The projected point's normal. */
87  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
88  };
89 
90  inline
91  MLSResult () : num_neighbors (0), curvature (0.0f), order (0), valid (false) {}
92 
93  inline
94  MLSResult (const Eigen::Vector3d &a_query_point,
95  const Eigen::Vector3d &a_mean,
96  const Eigen::Vector3d &a_plane_normal,
97  const Eigen::Vector3d &a_u,
98  const Eigen::Vector3d &a_v,
99  const Eigen::VectorXd &a_c_vec,
100  const int a_num_neighbors,
101  const float a_curvature,
102  const int a_order);
103 
104  /** \brief Given a point calculate it's 3D location in the MLS frame.
105  * \param[in] pt The point
106  * \param[out] u The u-coordinate of the point in local MLS frame.
107  * \param[out] v The v-coordinate of the point in local MLS frame.
108  * \param[out] w The w-coordinate of the point in local MLS frame.
109  */
110  inline void
111  getMLSCoordinates (const Eigen::Vector3d &pt, double &u, double &v, double &w) const;
112 
113  /** \brief Given a point calculate it's 2D location in the MLS frame.
114  * \param[in] pt The point
115  * \param[out] u The u-coordinate of the point in local MLS frame.
116  * \param[out] v The v-coordinate of the point in local MLS frame.
117  */
118  inline void
119  getMLSCoordinates (const Eigen::Vector3d &pt, double &u, double &v) const;
120 
121  /** \brief Calculate the polynomial
122  * \param[in] u The u-coordinate of the point in local MLS frame.
123  * \param[in] v The v-coordinate of the point in local MLS frame.
124  * \return The polynomial value at the provide uv coordinates.
125  */
126  inline double
127  getPolynomialValue (const double u, const double v) const;
128 
129  /** \brief Calculate the polynomial's first and second partial derivatives.
130  * \param[in] u The u-coordinate of the point in local MLS frame.
131  * \param[in] v The v-coordinate of the point in local MLS frame.
132  * \return The polynomial partial derivatives at the provide uv coordinates.
133  */
134  inline PolynomialPartialDerivative
135  getPolynomialPartialDerivative (const double u, const double v) const;
136 
137  /** \brief Calculate the principle curvatures using the polynomial surface.
138  * \param[in] u The u-coordinate of the point in local MLS frame.
139  * \param[in] v The v-coordinate of the point in local MLS frame.
140  * \return The principle curvature [k1, k2] at the provided ub coordinates.
141  * \note If an error occurs the MLS_MINIMUM_PRINCIPLE_CURVATURE is returned.
142  */
143  inline Eigen::Vector2f
144  calculatePrincipleCurvatures (const double u, const double v) const;
145 
146  /** \brief Project a point orthogonal to the polynomial surface.
147  * \param[in] u The u-coordinate of the point in local MLS frame.
148  * \param[in] v The v-coordinate of the point in local MLS frame.
149  * \param[in] w The w-coordinate of the point in local MLS frame.
150  * \return The MLSProjectionResults for the input data.
151  * \note If the MLSResults does not contain polynomial data it projects the point onto the mls plane.
152  * \note If the optimization diverges it performs a simple projection on to the polynomial surface.
153  * \note This was implemented based on this https://math.stackexchange.com/questions/1497093/shortest-distance-between-point-and-surface
154  */
155  inline MLSProjectionResults
156  projectPointOrthogonalToPolynomialSurface (const double u, const double v, const double w) const;
157 
158  /** \brief Project a point onto the MLS plane.
159  * \param[in] u The u-coordinate of the point in local MLS frame.
160  * \param[in] v The v-coordinate of the point in local MLS frame.
161  * \return The MLSProjectionResults for the input data.
162  */
163  inline MLSProjectionResults
164  projectPointToMLSPlane (const double u, const double v) const;
165 
166  /** \brief Project a point along the MLS plane normal to the polynomial surface.
167  * \param[in] u The u-coordinate of the point in local MLS frame.
168  * \param[in] v The v-coordinate of the point in local MLS frame.
169  * \return The MLSProjectionResults for the input data.
170  * \note If the MLSResults does not contain polynomial data it projects the point onto the mls plane.
171  */
172  inline MLSProjectionResults
173  projectPointSimpleToPolynomialSurface (const double u, const double v) const;
174 
175  /**
176  * \brief Project a point using the specified method.
177  * \param[in] pt The point to be project.
178  * \param[in] method The projection method to be used.
179  * \param[in] required_neighbors The minimum number of neighbors required.
180  * \note If required_neighbors then any number of neighbors is allowed.
181  * \note If required_neighbors is not satisfied it projects to the mls plane.
182  * \return The MLSProjectionResults for the input data.
183  */
184  inline MLSProjectionResults
185  projectPoint (const Eigen::Vector3d &pt, ProjectionMethod method, int required_neighbors = 0) const;
186 
187  /**
188  * \brief Project the query point used to generate the mls surface about using the specified method.
189  * \param[in] method The projection method to be used.
190  * \param[in] required_neighbors The minimum number of neighbors required.
191  * \note If required_neighbors then any number of neighbors is allowed.
192  * \note If required_neighbors is not satisfied it projects to the mls plane.
193  * \return The MLSProjectionResults for the input data.
194  */
195  inline MLSProjectionResults
196  projectQueryPoint (ProjectionMethod method, int required_neighbors = 0) const;
197 
198  /** \brief Smooth a given point and its neighborghood using Moving Least Squares.
199  * \param[in] index the index of the query point in the input cloud
200  * \param[in] nn_indices the set of nearest neighbors indices for pt
201  * \param[in] search_radius the search radius used to find nearest neighbors for pt
202  * \param[in] polynomial_order the order of the polynomial to fit to the nearest neighbors
203  * \param[in] weight_func defines the weight function for the polynomial fit
204  */
205  template <typename PointT> void
207  int index,
208  const std::vector<int> &nn_indices,
209  double search_radius,
210  int polynomial_order = 2,
211  boost::function<double(const double)> weight_func = 0);
212 
213  Eigen::Vector3d query_point; /**< \brief The query point about which the mls surface was generated */
214  Eigen::Vector3d mean; /**< \brief The mean point of all the neighbors. */
215  Eigen::Vector3d plane_normal; /**< \brief The normal of the local plane of the query point. */
216  Eigen::Vector3d u_axis; /**< \brief The axis corresponding to the u-coordinates of the local plane of the query point. */
217  Eigen::Vector3d v_axis; /**< \brief The axis corresponding to the v-coordinates of the local plane of the query point. */
218  Eigen::VectorXd c_vec; /**< \brief The polynomial coefficients Example: z = c_vec[0] + c_vec[1]*v + c_vec[2]*v^2 + c_vec[3]*u + c_vec[4]*u*v + c_vec[5]*u^2 */
219  int num_neighbors; /**< \brief The number of neighbors used to create the mls surface. */
220  float curvature; /**< \brief The curvature at the query point. */
221  int order; /**< \brief The order of the polynomial. If order > 1 then use polynomial fit */
222  bool valid; /**< \brief If True, the mls results data is valid, otherwise False. */
223  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
224  private:
225  /**
226  * \brief The default weight function used when fitting a polynomial surface
227  * \param sq_dist the squared distance from a point to origin of the mls frame
228  * \param sq_mls_radius the squraed mls search radius used
229  * \return The weight for a point at squared distance from the origin of the mls frame
230  */
231  inline
232  double computeMLSWeight (const double sq_dist, const double sq_mls_radius) { return (exp (-sq_dist / sq_mls_radius)); }
233 
234  };
235 
236  /** \brief MovingLeastSquares represent an implementation of the MLS (Moving Least Squares) algorithm
237  * for data smoothing and improved normal estimation. It also contains methods for upsampling the
238  * resulting cloud based on the parametric fit.
239  * Reference paper: "Computing and Rendering Point Set Surfaces" by Marc Alexa, Johannes Behr,
240  * Daniel Cohen-Or, Shachar Fleishman, David Levin and Claudio T. Silva
241  * www.sci.utah.edu/~shachar/Publications/crpss.pdf
242  * \note There is a parallelized version of the processing step, using the OpenMP standard.
243  * Compared to the standard version, an overhead is incurred in terms of runtime and memory usage.
244  * The upsampling methods DISTINCT_CLOUD and VOXEL_GRID_DILATION are not parallelized completely,
245  * i.e. parts of the algorithm run on a single thread only.
246  * \author Zoltan Csaba Marton, Radu B. Rusu, Alexandru E. Ichim, Suat Gedikli, Robert Huitl
247  * \ingroup surface
248  */
249  template <typename PointInT, typename PointOutT>
250  class MovingLeastSquares : public CloudSurfaceProcessing<PointInT, PointOutT>
251  {
252  public:
253  typedef boost::shared_ptr<MovingLeastSquares<PointInT, PointOutT> > Ptr;
254  typedef boost::shared_ptr<const MovingLeastSquares<PointInT, PointOutT> > ConstPtr;
255 
261 
266 
270 
274 
275  typedef boost::function<int (int, double, std::vector<int> &, std::vector<float> &)> SearchMethod;
276 
278  {
279  NONE, /**< \brief No upsampling will be done, only the input points will be projected
280  to their own MLS surfaces. */
281  DISTINCT_CLOUD, /**< \brief Project the points of the distinct cloud to the MLS surface. */
282  SAMPLE_LOCAL_PLANE, /**< \brief The local plane of each input point will be sampled in a circular fashion
283  using the \ref upsampling_radius_ and the \ref upsampling_step_ parameters. */
284  RANDOM_UNIFORM_DENSITY, /**< \brief The local plane of each input point will be sampled using an uniform random
285  distribution such that the density of points is constant throughout the
286  cloud - given by the \ref desired_num_points_in_radius_ parameter. */
287  VOXEL_GRID_DILATION /**< \brief The input cloud will be inserted into a voxel grid with voxels of
288  size \ref voxel_size_; this voxel grid will be dilated \ref dilation_iteration_num_
289  times and the resulting points will be projected to the MLS surface
290  of the closest point in the input cloud; the result is a point cloud
291  with filled holes and a constant point density. */
292  };
293 
294  /** \brief Empty constructor. */
295  MovingLeastSquares () : CloudSurfaceProcessing<PointInT, PointOutT> (),
296  normals_ (),
297  distinct_cloud_ (),
298  search_method_ (),
299  tree_ (),
300  order_ (2),
301  search_radius_ (0.0),
302  sqr_gauss_param_ (0.0),
303  compute_normals_ (false),
305  upsampling_radius_ (0.0),
306  upsampling_step_ (0.0),
308  cache_mls_results_ (true),
309  mls_results_ (),
310  projection_method_ (MLSResult::SIMPLE),
311  threads_ (1),
312  voxel_size_ (1.0),
314  nr_coeff_ (),
316  rng_alg_ (),
317  rng_uniform_distribution_ ()
318  {};
319 
320  /** \brief Empty destructor */
321  virtual ~MovingLeastSquares () {}
322 
323 
324  /** \brief Set whether the algorithm should also store the normals computed
325  * \note This is optional, but need a proper output cloud type
326  */
327  inline void
328  setComputeNormals (bool compute_normals) { compute_normals_ = compute_normals; }
329 
330  /** \brief Provide a pointer to the search object.
331  * \param[in] tree a pointer to the spatial search object.
332  */
333  inline void
335  {
336  tree_ = tree;
337  // Declare the search locator definition
338  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;
339  search_method_ = boost::bind (radiusSearch, boost::ref (tree_), _1, _2, _3, _4, 0);
340  }
341 
342  /** \brief Get a pointer to the search method used. */
343  inline KdTreePtr
344  getSearchMethod () const { return (tree_); }
345 
346  /** \brief Set the order of the polynomial to be fit.
347  * \param[in] order the order of the polynomial
348  * \note Setting order > 1 indicates using a polynomial fit.
349  */
350  inline void
351  setPolynomialOrder (int order) { order_ = order; }
352 
353  /** \brief Get the order of the polynomial to be fit. */
354  inline int
355  getPolynomialOrder () const { return (order_); }
356 
357  /** \brief Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimation.
358  * \param[in] polynomial_fit set to true for polynomial fit
359  */
360  PCL_DEPRECATED ("[pcl::surface::MovingLeastSquares::setPolynomialFit] setPolynomialFit is deprecated. Please use setPolynomialOrder instead.")
361  inline void
362  setPolynomialFit (bool polynomial_fit)
363  {
364  if (polynomial_fit)
365  {
366  if (order_ < 2)
367  {
368  order_ = 2;
369  }
370  }
371  else
372  {
373  order_ = 0;
374  }
375  }
376 
377  /** \brief Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial). */
378  PCL_DEPRECATED ("[pcl::surface::MovingLeastSquares::getPolynomialFit] getPolynomialFit is deprecated. Please use getPolynomialOrder instead.")
379  inline bool
380  getPolynomialFit () const { return (order_ > 1); }
381 
382  /** \brief Set the sphere radius that is to be used for determining the k-nearest neighbors used for fitting.
383  * \param[in] radius the sphere radius that is to contain all k-nearest neighbors
384  * \note Calling this method resets the squared Gaussian parameter to radius * radius !
385  */
386  inline void
388 
389  /** \brief Get the sphere radius used for determining the k-nearest neighbors. */
390  inline double
391  getSearchRadius () const { return (search_radius_); }
392 
393  /** \brief Set the parameter used for distance based weighting of neighbors (the square of the search radius works
394  * best in general).
395  * \param[in] sqr_gauss_param the squared Gaussian parameter
396  */
397  inline void
398  setSqrGaussParam (double sqr_gauss_param) { sqr_gauss_param_ = sqr_gauss_param; }
399 
400  /** \brief Get the parameter for distance based weighting of neighbors. */
401  inline double
402  getSqrGaussParam () const { return (sqr_gauss_param_); }
403 
404  /** \brief Set the upsampling method to be used
405  * \param method
406  */
407  inline void
409 
410  /** \brief Set the distinct cloud used for the DISTINCT_CLOUD upsampling method. */
411  inline void
412  setDistinctCloud (PointCloudInConstPtr distinct_cloud) { distinct_cloud_ = distinct_cloud; }
413 
414  /** \brief Get the distinct cloud used for the DISTINCT_CLOUD upsampling method. */
415  inline PointCloudInConstPtr
416  getDistinctCloud () const { return (distinct_cloud_); }
417 
418 
419  /** \brief Set the radius of the circle in the local point plane that will be sampled
420  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
421  * \param[in] radius the radius of the circle
422  */
423  inline void
424  setUpsamplingRadius (double radius) { upsampling_radius_ = radius; }
425 
426  /** \brief Get the radius of the circle in the local point plane that will be sampled
427  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
428  */
429  inline double
431 
432  /** \brief Set the step size for the local plane sampling
433  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
434  * \param[in] step_size the step size
435  */
436  inline void
437  setUpsamplingStepSize (double step_size) { upsampling_step_ = step_size; }
438 
439 
440  /** \brief Get the step size for the local plane sampling
441  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
442  */
443  inline double
445 
446  /** \brief Set the parameter that specifies the desired number of points within the search radius
447  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
448  * \param[in] desired_num_points_in_radius the desired number of points in the output cloud in a sphere of
449  * radius \ref search_radius_ around each point
450  */
451  inline void
452  setPointDensity (int desired_num_points_in_radius) { desired_num_points_in_radius_ = desired_num_points_in_radius; }
453 
454 
455  /** \brief Get the parameter that specifies the desired number of points within the search radius
456  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
457  */
458  inline int
460 
461  /** \brief Set the voxel size for the voxel grid
462  * \note Used only in the VOXEL_GRID_DILATION upsampling method
463  * \param[in] voxel_size the edge length of a cubic voxel in the voxel grid
464  */
465  inline void
466  setDilationVoxelSize (float voxel_size) { voxel_size_ = voxel_size; }
467 
468 
469  /** \brief Get the voxel size for the voxel grid
470  * \note Used only in the VOXEL_GRID_DILATION upsampling method
471  */
472  inline float
473  getDilationVoxelSize () const { return (voxel_size_); }
474 
475  /** \brief Set the number of dilation steps of the voxel grid
476  * \note Used only in the VOXEL_GRID_DILATION upsampling method
477  * \param[in] iterations the number of dilation iterations
478  */
479  inline void
480  setDilationIterations (int iterations) { dilation_iteration_num_ = iterations; }
481 
482  /** \brief Get the number of dilation steps of the voxel grid
483  * \note Used only in the VOXEL_GRID_DILATION upsampling method
484  */
485  inline int
487 
488  /** \brief Set whether the mls results should be stored for each point in the input cloud
489  * \param[in] True if the mls results should be stored, otherwise false.
490  * \note The cache_mls_results_ is forced to true when using upsampling method VOXEL_GRID_DILATION or DISTINCT_CLOUD.
491  * \note If memory consumption is a concern set to false when not using upsampling method VOXEL_GRID_DILATION or DISTINCT_CLOUD.
492  */
493  inline void
494  setCacheMLSResults (bool cache_mls_results) { cache_mls_results_ = cache_mls_results; }
495 
496  /** \brief Get the cache_mls_results_ value (True if the mls results should be stored, otherwise false). */
497  inline bool
498  getCacheMLSResults () const { return (cache_mls_results_); }
499 
500  /** \brief Set the method to be used when projection the point on to the MLS surface.
501  * \param method
502  * \note This is only used when polynomial fit is enabled.
503  */
504  inline void
506 
507 
508  /** \brief Get the current projection method being used. */
511 
512  /** \brief Get the MLSResults for input cloud
513  * \note The results are only stored if setCacheMLSResults(true) was called or when using the upsampling method DISTINCT_CLOUD or VOXEL_GRID_DILATION.
514  * \note This vector is align with the input cloud indices, so use getCorrespondingIndices to get the correct results when using output cloud indices.
515  */
516  inline const std::vector<MLSResult>&
517  getMLSResults () const { return (mls_results_); }
518 
519  /** \brief Set the maximum number of threads to use
520  * \param threads the maximum number of hardware threads to use (0 sets the value to 1)
521  */
522  inline void
523  setNumberOfThreads (unsigned int threads = 1)
524  {
525  threads_ = threads;
526  }
527 
528  /** \brief Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
529  * \param[out] output the resultant reconstructed surface model
530  */
531  void
532  process (PointCloudOut &output);
533 
534 
535  /** \brief Get the set of indices with each point in output having the
536  * corresponding point in input */
537  inline PointIndicesPtr
539 
540  protected:
541  /** \brief The point cloud that will hold the estimated normals, if set. */
543 
544  /** \brief The distinct point cloud that will be projected to the MLS surface. */
546 
547  /** \brief The search method template for indices. */
549 
550  /** \brief A pointer to the spatial search object. */
552 
553  /** \brief The order of the polynomial to be fit. */
554  int order_;
555 
556  /** \brief The nearest neighbors search radius for each point. */
558 
559  /** \brief Parameter for distance based weighting of neighbors (search_radius_ * search_radius_ works fine) */
561 
562  /** \brief Parameter that specifies whether the normals should be computed for the input cloud or not */
564 
565  /** \brief Parameter that specifies the upsampling method to be used */
567 
568  /** \brief Radius of the circle in the local point plane that will be sampled
569  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
570  */
572 
573  /** \brief Step size for the local plane sampling
574  * \note Used only in the case of SAMPLE_LOCAL_PLANE upsampling
575  */
577 
578  /** \brief Parameter that specifies the desired number of points within the search radius
579  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
580  */
582 
583  /** \brief True if the mls results for the input cloud should be stored
584  * \note This is forced to true when using upsampling methods VOXEL_GRID_DILATION or DISTINCT_CLOUD.
585  */
587 
588  /** \brief Stores the MLS result for each point in the input cloud
589  * \note Used only in the case of VOXEL_GRID_DILATION or DISTINCT_CLOUD upsampling
590  */
591  std::vector<MLSResult> mls_results_;
592 
593  /** \brief Parameter that specifies the projection method to be used. */
595 
596  /** \brief The maximum number of threads the scheduler should use. */
597  unsigned int threads_;
598 
599 
600  /** \brief A minimalistic implementation of a voxel grid, necessary for the point cloud upsampling
601  * \note Used only in the case of VOXEL_GRID_DILATION upsampling
602  */
604  {
605  public:
606  struct Leaf { Leaf () : valid (true) {} bool valid; };
607 
609  IndicesPtr &indices,
610  float voxel_size);
611 
612  void
613  dilate ();
614 
615  inline void
616  getIndexIn1D (const Eigen::Vector3i &index, uint64_t &index_1d) const
617  {
618  index_1d = index[0] * data_size_ * data_size_ +
619  index[1] * data_size_ + index[2];
620  }
621 
622  inline void
623  getIndexIn3D (uint64_t index_1d, Eigen::Vector3i& index_3d) const
624  {
625  index_3d[0] = static_cast<Eigen::Vector3i::Scalar> (index_1d / (data_size_ * data_size_));
626  index_1d -= index_3d[0] * data_size_ * data_size_;
627  index_3d[1] = static_cast<Eigen::Vector3i::Scalar> (index_1d / data_size_);
628  index_1d -= index_3d[1] * data_size_;
629  index_3d[2] = static_cast<Eigen::Vector3i::Scalar> (index_1d);
630  }
631 
632  inline void
633  getCellIndex (const Eigen::Vector3f &p, Eigen::Vector3i& index) const
634  {
635  for (int i = 0; i < 3; ++i)
636  index[i] = static_cast<Eigen::Vector3i::Scalar> ((p[i] - bounding_min_ (i)) / voxel_size_);
637  }
638 
639  inline void
640  getPosition (const uint64_t &index_1d, Eigen::Vector3f &point) const
641  {
642  Eigen::Vector3i index_3d;
643  getIndexIn3D (index_1d, index_3d);
644  for (int i = 0; i < 3; ++i)
645  point[i] = static_cast<Eigen::Vector3f::Scalar> (index_3d[i]) * voxel_size_ + bounding_min_[i];
646  }
647 
648  typedef std::map<uint64_t, Leaf> HashMap;
650  Eigen::Vector4f bounding_min_, bounding_max_;
651  uint64_t data_size_;
652  float voxel_size_;
653  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
654  };
655 
656 
657  /** \brief Voxel size for the VOXEL_GRID_DILATION upsampling method */
658  float voxel_size_;
659 
660  /** \brief Number of dilation steps for the VOXEL_GRID_DILATION upsampling method */
662 
663  /** \brief Number of coefficients, to be computed from the requested order.*/
665 
666  /** \brief Collects for each point in output the corrseponding point in the input. */
668 
669  /** \brief Search for the closest nearest neighbors of a given point using a radius search
670  * \param[in] index the index of the query point
671  * \param[out] indices the resultant vector of indices representing the k-nearest neighbors
672  * \param[out] sqr_distances the resultant squared distances from the query point to the k-nearest neighbors
673  */
674  inline int
675  searchForNeighbors (int index, std::vector<int> &indices, std::vector<float> &sqr_distances) const
676  {
677  return (search_method_ (index, search_radius_, indices, sqr_distances));
678  }
679 
680  /** \brief Smooth a given point and its neighborghood using Moving Least Squares.
681  * \param[in] index the index of the query point in the input cloud
682  * \param[in] nn_indices the set of nearest neighbors indices for pt
683  * \param[out] projected_points the set of points projected points around the query point
684  * (in the case of upsampling method NONE, only the query point projected to its own fitted surface will be returned,
685  * in the case of the other upsampling methods, multiple points will be returned)
686  * \param[out] projected_points_normals the normals corresponding to the projected points
687  * \param[out] corresponding_input_indices the set of indices with each point in output having the corresponding point in input
688  * \param[out] mls_result stores the MLS result for each point in the input cloud
689  * (used only in the case of VOXEL_GRID_DILATION or DISTINCT_CLOUD upsampling)
690  */
691  void
692  computeMLSPointNormal (int index,
693  const std::vector<int> &nn_indices,
694  PointCloudOut &projected_points,
695  NormalCloud &projected_points_normals,
696  PointIndices &corresponding_input_indices,
697  MLSResult &mls_result) const;
698 
699 
700  /** \brief This is a helper function for add projected points
701  * \param[in] index the index of the query point in the input cloud
702  * \param[in] point the projected point to be added
703  * \param[in] normal the projected point's normal to be added
704  * \param[in] curvature the projected point's curvature
705  * \param[out] projected_points the set of projected points around the query point
706  * \param[out] projected_points_normals the normals corresponding to the projected points
707  * \param[out] corresponding_input_indices the set of indices with each point in output having the corresponding point in input
708  */
709  void
710  addProjectedPointNormal (int index,
711  const Eigen::Vector3d &point,
712  const Eigen::Vector3d &normal,
713  double curvature,
714  PointCloudOut &projected_points,
715  NormalCloud &projected_points_normals,
716  PointIndices &corresponding_input_indices) const;
717 
718 
719  void
720  copyMissingFields (const PointInT &point_in,
721  PointOutT &point_out) const;
722 
723  /** \brief Abstract surface reconstruction method.
724  * \param[out] output the result of the reconstruction
725  */
726  virtual void
728 
729  /** \brief Perform upsampling for the distinct-cloud and voxel-grid methods
730  * \param[out] output the result of the reconstruction
731  */
732  void
734 
735  private:
736  /** \brief Boost-based random number generator algorithm. */
737  boost::mt19937 rng_alg_;
738 
739  /** \brief Random number generator using an uniform distribution of floats
740  * \note Used only in the case of RANDOM_UNIFORM_DENSITY upsampling
741  */
742  boost::shared_ptr<boost::variate_generator<boost::mt19937&,
743  boost::uniform_real<float> >
744  > rng_uniform_distribution_;
745 
746  /** \brief Abstract class get name method. */
747  std::string
748  getClassName () const { return ("MovingLeastSquares"); }
749  };
750 
751  /** \brief MovingLeastSquaresOMP implementation has been merged into MovingLeastSquares for better maintainability.
752  * \note Keeping this empty child class for backwards compatibility.
753  * \author Robert Huitl
754  * \ingroup surface
755  */
756  template <typename PointInT, typename PointOutT>
757  class MovingLeastSquaresOMP : public MovingLeastSquares<PointInT, PointOutT>
758  {
759  public:
760  /** \brief Constructor for parallelized Moving Least Squares
761  * \param threads the maximum number of hardware threads to use (0 sets the value to 1)
762  */
763  MovingLeastSquaresOMP (unsigned int threads = 1)
764  {
765  this->setNumberOfThreads (threads);
766  }
767  };
768 }
769 
770 #ifdef PCL_NO_PRECOMPILE
771 #include <pcl/surface/impl/mls.hpp>
772 #endif
773 
774 #endif /* #ifndef PCL_MLS_H_ */
pcl::MovingLeastSquares::setDilationIterations
void setDilationIterations(int iterations)
Set the number of dilation steps of the voxel grid.
Definition: mls.h:480
pcl::IndicesPtr
boost::shared_ptr< std::vector< int > > IndicesPtr
Definition: pcl_base.h:60
pcl::MLSResult::num_neighbors
int num_neighbors
The number of neighbors used to create the mls surface.
Definition: mls.h:219
pcl::search::Search< PointInT >
pcl::MLSResult::projectPointOrthogonalToPolynomialSurface
MLSProjectionResults projectPointOrthogonalToPolynomialSurface(const double u, const double v, const double w) const
Project a point orthogonal to the polynomial surface.
Definition: mls.hpp:565
pcl::MLSResult::mean
Eigen::Vector3d mean
The mean point of all the neighbors.
Definition: mls.h:214
pcl::MovingLeastSquares::MLSVoxelGrid::HashMap
std::map< uint64_t, Leaf > HashMap
Definition: mls.h:648
pcl::MLSResult::projectPointToMLSPlane
MLSProjectionResults projectPointToMLSPlane(const double u, const double v) const
Project a point onto the MLS plane.
Definition: mls.hpp:630
pcl::MovingLeastSquares::projection_method_
MLSResult::ProjectionMethod projection_method_
Parameter that specifies the projection method to be used.
Definition: mls.h:594
pcl::MovingLeastSquares::getPolynomialOrder
int getPolynomialOrder() const
Get the order of the polynomial to be fit.
Definition: mls.h:355
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::MovingLeastSquares::computeMLSPointNormal
void computeMLSPointNormal(int index, const std::vector< int > &nn_indices, 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:171
pcl::MovingLeastSquares::dilation_iteration_num_
int dilation_iteration_num_
Number of dilation steps for the VOXEL_GRID_DILATION upsampling method.
Definition: mls.h:661
pcl::PointCloud::Ptr
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
pcl::MovingLeastSquares::setComputeNormals
void setComputeNormals(bool compute_normals)
Set whether the algorithm should also store the normals computed.
Definition: mls.h:328
pcl::MovingLeastSquares::MLSVoxelGrid::getIndexIn3D
void getIndexIn3D(uint64_t index_1d, Eigen::Vector3i &index_3d) const
Definition: mls.h:623
common.h
pcl::MovingLeastSquares::getDistinctCloud
PointCloudInConstPtr getDistinctCloud() const
Get the distinct cloud used for the DISTINCT_CLOUD upsampling method.
Definition: mls.h:416
pcl::MovingLeastSquares::setUpsamplingMethod
void setUpsamplingMethod(UpsamplingMethod method)
Set the upsampling method to be used.
Definition: mls.h:408
pcl::MovingLeastSquares::MLSVoxelGrid::getCellIndex
void getCellIndex(const Eigen::Vector3f &p, Eigen::Vector3i &index) const
Definition: mls.h:633
pcl::MovingLeastSquares::addProjectedPointNormal
void addProjectedPointNormal(int index, const Eigen::Vector3d &point, const Eigen::Vector3d &normal, double curvature, PointCloudOut &projected_points, NormalCloud &projected_points_normals, PointIndices &corresponding_input_indices) const
This is a helper function for add projected points.
Definition: mls.hpp:249
pcl::MovingLeastSquares::setPolynomialOrder
void setPolynomialOrder(int order)
Set the order of the polynomial to be fit.
Definition: mls.h:351
pcl::MLSResult::PolynomialPartialDerivative::z_uu
double z_uu
The partial derivative d^2z/du^2.
Definition: mls.h:73
pcl::MovingLeastSquares::PointCloudOutPtr
PointCloudOut::Ptr PointCloudOutPtr
Definition: mls.h:268
pcl::MovingLeastSquares
MovingLeastSquares represent an implementation of the MLS (Moving Least Squares) algorithm for data s...
Definition: mls.h:250
pcl::search::Search::Ptr
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
pcl::MovingLeastSquares::MLSVoxelGrid
A minimalistic implementation of a voxel grid, necessary for the point cloud upsampling.
Definition: mls.h:603
pcl::MovingLeastSquares::sqr_gauss_param_
double sqr_gauss_param_
Parameter for distance based weighting of neighbors (search_radius_ * search_radius_ works fine)
Definition: mls.h:560
pcl::MLSResult::MLSResult
MLSResult()
Definition: mls.h:91
pcl::MLSResult::MLSProjectionResults::u
double u
The u-coordinate of the projected point in local MLS frame.
Definition: mls.h:83
pcl::MovingLeastSquaresOMP
MovingLeastSquaresOMP implementation has been merged into MovingLeastSquares for better maintainabili...
Definition: mls.h:757
pcl::MovingLeastSquares::MLSVoxelGrid::MLSVoxelGrid
MLSVoxelGrid(PointCloudInConstPtr &cloud, IndicesPtr &indices, float voxel_size)
Definition: mls.hpp:831
pcl::MovingLeastSquares::ConstPtr
boost::shared_ptr< const MovingLeastSquares< PointInT, PointOutT > > ConstPtr
Definition: mls.h:254
pcl::MovingLeastSquares::setUpsamplingRadius
void setUpsamplingRadius(double radius)
Set the radius of the circle in the local point plane that will be sampled.
Definition: mls.h:424
pcl::MLSResult::computeMLSSurface
void computeMLSSurface(const pcl::PointCloud< PointT > &cloud, int index, const std::vector< int > &nn_indices, double search_radius, int polynomial_order=2, boost::function< double(const double)> weight_func=0)
Smooth a given point and its neighborghood using Moving Least Squares.
Definition: mls.hpp:718
pcl::MLSResult::curvature
float curvature
The curvature at the query point.
Definition: mls.h:220
pcl::MovingLeastSquares::getPolynomialFit
bool getPolynomialFit() const
Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial).
Definition: mls.h:380
pcl::MovingLeastSquares::MLSVoxelGrid::getIndexIn1D
void getIndexIn1D(const Eigen::Vector3i &index, uint64_t &index_1d) const
Definition: mls.h:616
pcl::MovingLeastSquares::getPointDensity
int getPointDensity() const
Get the parameter that specifies the desired number of points within the search radius.
Definition: mls.h:459
pcl::MovingLeastSquares::getProjectionMethod
MLSResult::ProjectionMethod getProjectionMethod() const
Get the current projection method being used.
Definition: mls.h:510
pcl::PCLBase
PCL base class.
Definition: pcl_base.h:68
pcl::MovingLeastSquares::copyMissingFields
void copyMissingFields(const PointInT &point_in, PointOutT &point_out) const
Definition: mls.hpp:886
pcl::MLSResult::MLSProjectionResults::point
Eigen::Vector3d point
The projected point.
Definition: mls.h:85
pcl::MovingLeastSquares::UpsamplingMethod
UpsamplingMethod
Definition: mls.h:277
pcl::MovingLeastSquares::setSearchRadius
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:387
pcl::MovingLeastSquares::MovingLeastSquares
MovingLeastSquares()
Empty constructor.
Definition: mls.h:295
pcl::MLSResult::MLSProjectionResults::normal
Eigen::Vector3d normal
The projected point's normal.
Definition: mls.h:86
pcl::MLSResult::c_vec
Eigen::VectorXd c_vec
The polynomial coefficients Example: z = c_vec[0] + c_vec[1]*v + c_vec[2]*v^2 + c_vec[3]*u + c_vec[4]...
Definition: mls.h:218
pcl::MovingLeastSquares::PointCloudInPtr
PointCloudIn::Ptr PointCloudInPtr
Definition: mls.h:272
pcl::MovingLeastSquares::MLSVoxelGrid::bounding_max_
Eigen::Vector4f bounding_max_
Definition: mls.h:650
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:53
pcl::MovingLeastSquares::KdTree
pcl::search::Search< PointInT > KdTree
Definition: mls.h:262
pcl::MovingLeastSquares::Ptr
boost::shared_ptr< MovingLeastSquares< PointInT, PointOutT > > Ptr
Definition: mls.h:253
pcl::MLSResult::PolynomialPartialDerivative::z_vv
double z_vv
The partial derivative d^2z/dv^2.
Definition: mls.h:74
pcl::MovingLeastSquares::upsampling_radius_
double upsampling_radius_
Radius of the circle in the local point plane that will be sampled.
Definition: mls.h:571
pcl::MovingLeastSquares::NONE
@ NONE
No upsampling will be done, only the input points will be projected to their own MLS surfaces.
Definition: mls.h:279
pcl::MovingLeastSquares::mls_results_
std::vector< MLSResult > mls_results_
Stores the MLS result for each point in the input cloud.
Definition: mls.h:591
pcl::MLSResult::query_point
Eigen::Vector3d query_point
The query point about which the mls surface was generated.
Definition: mls.h:213
pcl::MLSResult::SIMPLE
@ SIMPLE
Project along the mls plane normal to the polynomial surface.
Definition: mls.h:63
pcl::MovingLeastSquares::distinct_cloud_
PointCloudInConstPtr distinct_cloud_
The distinct point cloud that will be projected to the MLS surface.
Definition: mls.h:545
pcl::MLSResult::PolynomialPartialDerivative::z_v
double z_v
The partial derivative dz/dv.
Definition: mls.h:72
pcl::MovingLeastSquares::getSearchRadius
double getSearchRadius() const
Get the sphere radius used for determining the k-nearest neighbors.
Definition: mls.h:391
pcl::MovingLeastSquares::MLSVoxelGrid::dilate
void dilate()
Definition: mls.hpp:857
pcl::MovingLeastSquares::performUpsampling
void performUpsampling(PointCloudOut &output)
Perform upsampling for the distinct-cloud and voxel-grid methods.
Definition: mls.hpp:365
pcl::MovingLeastSquares::PointCloudOutConstPtr
PointCloudOut::ConstPtr PointCloudOutConstPtr
Definition: mls.h:269
pcl::MovingLeastSquares::MLSVoxelGrid::Leaf::valid
bool valid
Definition: mls.h:606
pcl::MovingLeastSquares::search_method_
SearchMethod search_method_
The search method template for indices.
Definition: mls.h:548
pcl::MLSResult::plane_normal
Eigen::Vector3d plane_normal
The normal of the local plane of the query point.
Definition: mls.h:215
pcl::MLSResult::ORTHOGONAL
@ ORTHOGONAL
Project to the closest point on the polynonomial surface.
Definition: mls.h:64
pcl::MovingLeastSquares::MLSVoxelGrid::getPosition
void getPosition(const uint64_t &index_1d, Eigen::Vector3f &point) const
Definition: mls.h:640
pcl::PCLBase< PointInT >::PointIndicesPtr
boost::shared_ptr< PointIndices > PointIndicesPtr
Definition: pcl_base.h:75
pcl::MLSResult::calculatePrincipleCurvatures
Eigen::Vector2f calculatePrincipleCurvatures(const double u, const double v) const
Calculate the principle curvatures using the polynomial surface.
Definition: mls.hpp:533
pcl::MLSResult::getPolynomialPartialDerivative
PolynomialPartialDerivative getPolynomialPartialDerivative(const double u, const double v) const
Calculate the polynomial's first and second partial derivatives.
Definition: mls.hpp:488
pcl::MovingLeastSquares::setPolynomialFit
void setPolynomialFit(bool polynomial_fit)
Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimati...
Definition: mls.h:362
pcl::MLSResult::MLSProjectionResults::v
double v
The u-coordinate of the projected point in local MLS frame.
Definition: mls.h:84
pcl::MLSResult::ProjectionMethod
ProjectionMethod
Definition: mls.h:60
pcl::MovingLeastSquares::setCacheMLSResults
void setCacheMLSResults(bool cache_mls_results)
Set whether the mls results should be stored for each point in the input cloud.
Definition: mls.h:494
pcl::MovingLeastSquares::PointCloudIn
pcl::PointCloud< PointInT > PointCloudIn
Definition: mls.h:271
pcl::MovingLeastSquares::threads_
unsigned int threads_
The maximum number of threads the scheduler should use.
Definition: mls.h:597
pcl::MovingLeastSquares::search_radius_
double search_radius_
The nearest neighbors search radius for each point.
Definition: mls.h:557
pcl::MLSResult
Data structure used to store the results of the MLS fitting.
Definition: mls.h:58
pcl::MLSResult::PolynomialPartialDerivative
Data structure used to store the MLS polynomial partial derivatives.
Definition: mls.h:68
pcl::MovingLeastSquares::getCacheMLSResults
bool getCacheMLSResults() const
Get the cache_mls_results_ value (True if the mls results should be stored, otherwise false).
Definition: mls.h:498
pcl::MovingLeastSquares::SAMPLE_LOCAL_PLANE
@ SAMPLE_LOCAL_PLANE
The local plane of each input point will be sampled in a circular fashion using the upsampling_radius...
Definition: mls.h:282
pcl::MovingLeastSquares::setProjectionMethod
void setProjectionMethod(MLSResult::ProjectionMethod method)
Set the method to be used when projection the point on to the MLS surface.
Definition: mls.h:505
pcl::MovingLeastSquares::cache_mls_results_
bool cache_mls_results_
True if the mls results for the input cloud should be stored.
Definition: mls.h:586
pcl::MovingLeastSquaresOMP::MovingLeastSquaresOMP
MovingLeastSquaresOMP(unsigned int threads=1)
Constructor for parallelized Moving Least Squares.
Definition: mls.h:763
pcl::MovingLeastSquares::setUpsamplingStepSize
void setUpsamplingStepSize(double step_size)
Set the step size for the local plane sampling.
Definition: mls.h:437
pcl::MLSResult::PolynomialPartialDerivative::z_u
double z_u
The partial derivative dz/du.
Definition: mls.h:71
pcl::MLSResult::PolynomialPartialDerivative::z_uv
double z_uv
The partial derivative d^2z/dudv.
Definition: mls.h:75
pcl::CloudSurfaceProcessing
CloudSurfaceProcessing represents the base class for algorithms that takes a point cloud as input and...
Definition: processing.h:57
pcl::MovingLeastSquares::DISTINCT_CLOUD
@ DISTINCT_CLOUD
Project the points of the distinct cloud to the MLS surface.
Definition: mls.h:281
pcl::MLSResult::MLSProjectionResults
Data structure used to store the MLS projection results.
Definition: mls.h:79
pcl::MovingLeastSquares::PointCloudOut
pcl::PointCloud< PointOutT > PointCloudOut
Definition: mls.h:267
pcl::MovingLeastSquares::compute_normals_
bool compute_normals_
Parameter that specifies whether the normals should be computed for the input cloud or not.
Definition: mls.h:563
pcl::MovingLeastSquares::KdTreePtr
pcl::search::Search< PointInT >::Ptr KdTreePtr
Definition: mls.h:263
pcl::MovingLeastSquares::getSqrGaussParam
double getSqrGaussParam() const
Get the parameter for distance based weighting of neighbors.
Definition: mls.h:402
pcl::MovingLeastSquares::getSearchMethod
KdTreePtr getSearchMethod() const
Get a pointer to the search method used.
Definition: mls.h:344
pcl::MLSResult::order
int order
The order of the polynomial.
Definition: mls.h:221
pcl::MovingLeastSquares::getUpsamplingStepSize
double getUpsamplingStepSize() const
Get the step size for the local plane sampling.
Definition: mls.h:444
pcl::MovingLeastSquares::desired_num_points_in_radius_
int desired_num_points_in_radius_
Parameter that specifies the desired number of points within the search radius.
Definition: mls.h:581
pcl::PointIndices
Definition: PointIndices.h:12
pcl::search::Search< PointInT >::radiusSearch
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.
pcl::MovingLeastSquares::process
void process(PointCloudOut &output)
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
Definition: mls.hpp:58
pcl::MovingLeastSquares::MLSVoxelGrid::voxel_size_
float voxel_size_
Definition: mls.h:652
pcl::MovingLeastSquares::SearchMethod
boost::function< int(int, double, std::vector< int > &, std::vector< float > &)> SearchMethod
Definition: mls.h:275
pcl::MovingLeastSquares::upsampling_step_
double upsampling_step_
Step size for the local plane sampling.
Definition: mls.h:576
pcl::MovingLeastSquares::setPointDensity
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:452
pcl::MLSResult::valid
bool valid
If True, the mls results data is valid, otherwise False.
Definition: mls.h:222
pcl::MovingLeastSquares::voxel_size_
float voxel_size_
Voxel size for the VOXEL_GRID_DILATION upsampling method.
Definition: mls.h:658
pcl::MovingLeastSquares::setDistinctCloud
void setDistinctCloud(PointCloudInConstPtr distinct_cloud)
Set the distinct cloud used for the DISTINCT_CLOUD upsampling method.
Definition: mls.h:412
pcl::MovingLeastSquares::PointCloudInConstPtr
PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: mls.h:273
pcl::MLSResult::MLSProjectionResults::MLSProjectionResults
MLSProjectionResults()
Definition: mls.h:81
pcl::PointCloud::ConstPtr
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
pcl::MLSResult::projectQueryPoint
MLSProjectionResults projectQueryPoint(ProjectionMethod method, int required_neighbors=0) const
Project the query point used to generate the mls surface about using the specified method.
Definition: mls.hpp:687
pcl::MovingLeastSquares::getMLSResults
const std::vector< MLSResult > & getMLSResults() const
Get the MLSResults for input cloud.
Definition: mls.h:517
pcl::PointIndicesPtr
boost::shared_ptr< ::pcl::PointIndices > PointIndicesPtr
Definition: PointIndices.h:26
pcl::MovingLeastSquares::MLSVoxelGrid::bounding_min_
Eigen::Vector4f bounding_min_
Definition: mls.h:650
pcl::MLSResult::v_axis
Eigen::Vector3d v_axis
The axis corresponding to the v-coordinates of the local plane of the query point.
Definition: mls.h:217
pcl::MLSResult::projectPointSimpleToPolynomialSurface
MLSProjectionResults projectPointSimpleToPolynomialSurface(const double u, const double v) const
Project a point along the MLS plane normal to the polynomial surface.
Definition: mls.hpp:642
pcl::MovingLeastSquares::setSqrGaussParam
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:398
pcl::MovingLeastSquares::RANDOM_UNIFORM_DENSITY
@ RANDOM_UNIFORM_DENSITY
The local plane of each input point will be sampled using an uniform random distribution such that th...
Definition: mls.h:284
pcl::MovingLeastSquares::setNumberOfThreads
void setNumberOfThreads(unsigned int threads=1)
Set the maximum number of threads to use.
Definition: mls.h:523
pcl::MovingLeastSquares::getUpsamplingRadius
double getUpsamplingRadius() const
Get the radius of the circle in the local point plane that will be sampled.
Definition: mls.h:430
pcl::MovingLeastSquares::upsample_method_
UpsamplingMethod upsample_method_
Parameter that specifies the upsampling method to be used.
Definition: mls.h:566
pcl::MovingLeastSquares::MLSVoxelGrid::voxel_grid_
HashMap voxel_grid_
Definition: mls.h:649
pcl::MLSResult::PolynomialPartialDerivative::z
double z
The z component of the polynomial evaluated at z(u, v).
Definition: mls.h:70
pcl::MLSResult::projectPoint
MLSProjectionResults projectPoint(const Eigen::Vector3d &pt, ProjectionMethod method, int required_neighbors=0) const
Project a point using the specified method.
Definition: mls.hpp:665
pcl::MovingLeastSquares::order_
int order_
The order of the polynomial to be fit.
Definition: mls.h:554
pcl::MovingLeastSquares::NormalCloudPtr
pcl::PointCloud< pcl::Normal >::Ptr NormalCloudPtr
Definition: mls.h:265
pcl::MLSResult::getPolynomialValue
double getPolynomialValue(const double u, const double v) const
Calculate the polynomial.
Definition: mls.hpp:465
pcl::MovingLeastSquares::tree_
KdTreePtr tree_
A pointer to the spatial search object.
Definition: mls.h:551
pcl::MovingLeastSquares::MLSVoxelGrid::Leaf
Definition: mls.h:606
pcl::MovingLeastSquares::nr_coeff_
int nr_coeff_
Number of coefficients, to be computed from the requested order.
Definition: mls.h:664
pcl::MovingLeastSquares::getCorrespondingIndices
PointIndicesPtr getCorrespondingIndices() const
Get the set of indices with each point in output having the corresponding point in input.
Definition: mls.h:538
pcl::MLSResult::getMLSCoordinates
void getMLSCoordinates(const Eigen::Vector3d &pt, double &u, double &v, double &w) const
Given a point calculate it's 3D location in the MLS frame.
Definition: mls.hpp:448
pcl::MovingLeastSquares::setDilationVoxelSize
void setDilationVoxelSize(float voxel_size)
Set the voxel size for the voxel grid.
Definition: mls.h:466
pcl::MLSResult::NONE
@ NONE
Project to the mls plane.
Definition: mls.h:62
pcl::MovingLeastSquares::normals_
NormalCloudPtr normals_
The point cloud that will hold the estimated normals, if set.
Definition: mls.h:542
pcl::MovingLeastSquares::MLSVoxelGrid::data_size_
uint64_t data_size_
Definition: mls.h:651
pcl::MovingLeastSquares::VOXEL_GRID_DILATION
@ VOXEL_GRID_DILATION
The input cloud will be inserted into a voxel grid with voxels of size voxel_size_; this voxel grid w...
Definition: mls.h:287
pcl::MovingLeastSquares::setSearchMethod
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
Definition: mls.h:334
pcl::MovingLeastSquares::~MovingLeastSquares
virtual ~MovingLeastSquares()
Empty destructor.
Definition: mls.h:321
pcl::MovingLeastSquares::MLSVoxelGrid::Leaf::Leaf
Leaf()
Definition: mls.h:606
pcl::MovingLeastSquares::searchForNeighbors
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:675
pcl::MovingLeastSquares::NormalCloud
pcl::PointCloud< pcl::Normal > NormalCloud
Definition: mls.h:264
pcl::MovingLeastSquares::getDilationVoxelSize
float getDilationVoxelSize() const
Get the voxel size for the voxel grid.
Definition: mls.h:473
pcl::MovingLeastSquares::getDilationIterations
int getDilationIterations() const
Get the number of dilation steps of the voxel grid.
Definition: mls.h:486
pcl::MovingLeastSquares::performProcessing
virtual void performProcessing(PointCloudOut &output)
Abstract surface reconstruction method.
Definition: mls.hpp:281
pcl::MovingLeastSquares::corresponding_input_indices_
PointIndicesPtr corresponding_input_indices_
Collects for each point in output the corrseponding point in the input.
Definition: mls.h:667
pcl::MLSResult::u_axis
Eigen::Vector3d u_axis
The axis corresponding to the u-coordinates of the local plane of the query point.
Definition: mls.h:216