44 #include <pcl/pcl_base.h> 45 #include <pcl/search/pcl_search.h> 48 #include <pcl/surface/boost.h> 49 #include <pcl/surface/eigen.h> 50 #include <pcl/surface/processing.h> 64 template <
typename Po
intInT,
typename Po
intOutT>
68 typedef boost::shared_ptr<MovingLeastSquares<PointInT, PointOutT> >
Ptr;
69 typedef boost::shared_ptr<const MovingLeastSquares<PointInT, PointOutT> >
ConstPtr;
90 typedef boost::function<int (int, double, std::vector<int> &, std::vector<float> &)>
SearchMethod;
115 rng_uniform_distribution_ ()
136 int (
KdTree::*radiusSearch)(
int index,
double radius, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
unsigned int max_nn)
const = &
KdTree::radiusSearch;
352 MLSResult (
const Eigen::Vector3d &a_mean,
353 const Eigen::Vector3d &a_plane_normal,
354 const Eigen::Vector3d &a_u,
355 const Eigen::Vector3d &a_v,
356 const Eigen::VectorXd a_c_vec,
357 const int a_num_neighbors,
358 const float &a_curvature);
400 index_3d[1] =
static_cast<Eigen::Vector3i::Scalar
> (index_1d /
data_size_);
402 index_3d[2] =
static_cast<Eigen::Vector3i::Scalar
> (index_1d);
408 for (
int i = 0; i < 3; ++i)
413 getPosition (
const uint64_t &index_1d, Eigen::Vector3f &point)
const 415 Eigen::Vector3i index_3d;
417 for (
int i = 0; i < 3; ++i)
466 const std::vector<int> &nn_indices,
467 std::vector<float> &nn_sqr_dists,
471 MLSResult &mls_result)
const;
489 Eigen::Vector3d &u_axis, Eigen::Vector3d &v_axis,
490 Eigen::Vector3d &n_axis,
491 Eigen::Vector3d &mean,
493 Eigen::VectorXd &c_vec,
495 PointOutT &result_point,
500 PointOutT &point_out)
const;
514 boost::mt19937 rng_alg_;
519 boost::shared_ptr<boost::variate_generator<boost::mt19937&,
520 boost::uniform_real<float> >
521 > rng_uniform_distribution_;
524 std::string getClassName ()
const {
return (
"MovingLeastSquares"); }
527 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
537 template <
typename Po
intInT,
typename Po
intOutT>
538 class MovingLeastSquaresOMP:
public MovingLeastSquares<PointInT, PointOutT>
541 typedef boost::shared_ptr<MovingLeastSquares<PointInT, PointOutT> > Ptr;
542 typedef boost::shared_ptr<const MovingLeastSquares<PointInT, PointOutT> > ConstPtr;
559 typedef typename PointCloudOut::Ptr PointCloudOutPtr;
560 typedef typename PointCloudOut::ConstPtr PointCloudOutConstPtr;
565 MovingLeastSquaresOMP (
unsigned int threads = 0) : threads_ (threads)
574 setNumberOfThreads (
unsigned int threads = 0)
583 virtual void performProcessing (PointCloudOut &output);
586 unsigned int threads_;
591 #ifdef PCL_NO_PRECOMPILE 592 #include <pcl/surface/impl/mls.hpp>
A point structure representing normal coordinates and the surface curvature estimate.
int nr_coeff_
Number of coefficients, to be computed from the requested order.
pcl::PointCloud< pcl::Normal > NormalCloud
PointCloudOut::Ptr PointCloudOutPtr
NormalCloudPtr normals_
The point cloud that will hold the estimated normals, if set.
void setDilationVoxelSize(float voxel_size)
Set the voxel size for the voxel grid.
void setSearchRadius(double radius)
Set the sphere radius that is to be used for determining the k-nearest neighbors used for fitting...
int getPolynomialOrder()
Get the order of the polynomial to be fit.
PointCloudIn::Ptr PointCloudInPtr
int dilation_iteration_num_
Number of dilation steps for the VOXEL_GRID_DILATION upsampling method.
double getUpsamplingRadius()
Get the radius of the circle in the local point plane that will be sampled.
void setUpsamplingMethod(UpsamplingMethod method)
Set the upsampling method to be used.
virtual void performProcessing(PointCloudOut &output)
Abstract surface reconstruction method.
boost::shared_ptr< MovingLeastSquares< PointInT, PointOutT > > Ptr
boost::shared_ptr< std::vector< int > > IndicesPtr
pcl::search::Search< PointInT > KdTree
void getIndexIn1D(const Eigen::Vector3i &index, uint64_t &index_1d) const
PointIndicesPtr corresponding_input_indices_
Collects for each point in output the corrseponding point in the input.
void setPolynomialOrder(int order)
Set the order of the polynomial to be fit.
virtual int radiusSearch(const PointInT &point, double radius, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const=0
Search for all the nearest neighbors of the query point in a given radius.
MovingLeastSquares()
Empty constructor.
MovingLeastSquares represent an implementation of the MLS (Moving Least Squares) algorithm for data s...
IndicesPtr indices_
A pointer to the vector of point indices to use.
Eigen::Vector4f bounding_max_
KdTreePtr getSearchMethod()
Get a pointer to the search method used.
SearchMethod search_method_
The search method template for indices.
bool polynomial_fit_
True if the surface and normal be approximated using a polynomial, false if tangent estimation is suf...
CloudSurfaceProcessing represents the base class for algorithms that takes a point cloud as input and...
pcl::PointCloud< PointInT > PointCloudIn
boost::shared_ptr< PointIndices > PointIndicesPtr
void copyMissingFields(const PointInT &point_in, PointOutT &point_out) const
void setUpsamplingRadius(double radius)
Set the radius of the circle in the local point plane that will be sampled.
boost::shared_ptr< const MovingLeastSquares< PointInT, PointOutT > > ConstPtr
double getSearchRadius()
Get the sphere radius used for determining the k-nearest neighbors.
Eigen::Vector4f bounding_min_
boost::shared_ptr< PointCloud< PointT > > Ptr
std::vector< MLSResult > mls_results_
Stores the MLS result for each point in the input cloud.
Define standard C methods and C++ classes that are common to all methods.
double getUpsamplingStepSize()
Get the step size for the local plane sampling.
pcl::PointCloud< PointOutT > PointCloudOut
PointCloudOut::ConstPtr PointCloudOutConstPtr
double upsampling_radius_
Radius of the circle in the local point plane that will be sampled.
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
PointCloudInConstPtr distinct_cloud_
The distinct point cloud that will be projected to the MLS surface.
pcl::search::Search< PointInT >::Ptr KdTreePtr
void performUpsampling(PointCloudOut &output)
Perform upsampling for the distinct-cloud and voxel-grid methods.
void setDistinctCloud(PointCloudInConstPtr distinct_cloud)
Set the distinct cloud used for the DISTINCT_CLOUD upsampling method.
double search_radius_
The nearest neighbors search radius for each point.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
void setUpsamplingStepSize(double step_size)
Set the step size for the local plane sampling.
void setPolynomialFit(bool polynomial_fit)
Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimati...
double upsampling_step_
Step size for the local plane sampling.
void process(PointCloudOut &output)
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()> ...
int getPointDensity()
Get the parameter that specifies the desired number of points within the search radius.
void setSqrGaussParam(double sqr_gauss_param)
Set the parameter used for distance based weighting of neighbors (the square of the search radius wor...
PointCloudIn::ConstPtr PointCloudInConstPtr
KdTreePtr tree_
A pointer to the spatial search object.
boost::shared_ptr< ::pcl::PointIndices > PointIndicesPtr
A minimalistic implementation of a voxel grid, necessary for the point cloud upsampling.
void computeMLSPointNormal(int index, const std::vector< int > &nn_indices, std::vector< float > &nn_sqr_dists, PointCloudOut &projected_points, NormalCloud &projected_points_normals, PointIndices &corresponding_input_indices, MLSResult &mls_result) const
Smooth a given point and its neighborghood using Moving Least Squares.
MLSVoxelGrid(PointCloudInConstPtr &cloud, IndicesPtr &indices, float voxel_size)
PointIndicesPtr getCorrespondingIndices()
Get the set of indices with each point in output having the corresponding point in input...
Eigen::Vector3d plane_normal
int order_
The order of the polynomial to be fit.
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
bool getPolynomialFit()
Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial)...
int getDilationIterations()
Get the number of dilation steps of the voxel grid.
float voxel_size_
Voxel size for the VOXEL_GRID_DILATION upsampling method.
bool compute_normals_
Parameter that specifies whether the normals should be computed for the input cloud or not...
int desired_num_points_in_radius_
Parameter that specifies the desired number of points within the search radius.
double getSqrGaussParam() const
Get the parameter for distance based weighting of neighbors.
void getIndexIn3D(uint64_t index_1d, Eigen::Vector3i &index_3d) const
float getDilationVoxelSize()
Get the voxel size for the voxel grid.
void getPosition(const uint64_t &index_1d, Eigen::Vector3f &point) const
void setDilationIterations(int iterations)
Set the number of dilation steps of the voxel grid.
boost::function< int(int, double, std::vector< int > &, std::vector< float > &)> SearchMethod
PointCloudConstPtr input_
The input point cloud dataset.
void setPointDensity(int desired_num_points_in_radius)
Set the parameter that specifies the desired number of points within the search radius.
void setComputeNormals(bool compute_normals)
Set whether the algorithm should also store the normals computed.
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.
UpsamplingMethod upsample_method_
Parameter that specifies the upsampling method to be used.
virtual ~MovingLeastSquares()
Empty destructor.
void projectPointToMLSSurface(float &u_disp, float &v_disp, Eigen::Vector3d &u_axis, Eigen::Vector3d &v_axis, Eigen::Vector3d &n_axis, Eigen::Vector3d &mean, float &curvature, Eigen::VectorXd &c_vec, int num_neighbors, PointOutT &result_point, pcl::Normal &result_normal) const
Fits a point (sample point) given in the local plane coordinates of an input point (query point) to t...
PointCloudInConstPtr getDistinctCloud()
Get the distinct cloud used for the DISTINCT_CLOUD upsampling method.
pcl::PointCloud< pcl::Normal >::Ptr NormalCloudPtr
void getCellIndex(const Eigen::Vector3f &p, Eigen::Vector3i &index) const
Data structure used to store the results of the MLS fitting.
double sqr_gauss_param_
Parameter for distance based weighting of neighbors (search_radius_ * search_radius_ works fine) ...
std::map< uint64_t, Leaf > HashMap