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