44 #include <pcl/pcl_base.h>
45 #include <pcl/search/pcl_search.h>
46 #include <pcl/common/common.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;
351 MLSResult (
const Eigen::Vector3d &a_mean,
352 const Eigen::Vector3d &a_plane_normal,
353 const Eigen::Vector3d &a_u,
354 const Eigen::Vector3d &a_v,
355 const Eigen::VectorXd a_c_vec,
356 const int a_num_neighbors,
357 const float &a_curvature);
399 index_3d[1] =
static_cast<Eigen::Vector3i::Scalar
> (index_1d /
data_size_);
401 index_3d[2] =
static_cast<Eigen::Vector3i::Scalar
> (index_1d);
407 for (
int i = 0; i < 3; ++i)
412 getPosition (
const uint64_t &index_1d, Eigen::Vector3f &point)
const
414 Eigen::Vector3i index_3d;
416 for (
int i = 0; i < 3; ++i)
465 const std::vector<int> &nn_indices,
466 std::vector<float> &nn_sqr_dists,
470 MLSResult &mls_result)
const;
488 Eigen::Vector3d &u_axis, Eigen::Vector3d &v_axis,
489 Eigen::Vector3d &n_axis,
490 Eigen::Vector3d &mean,
492 Eigen::VectorXd &c_vec,
494 PointOutT &result_point,
499 PointOutT &point_out)
const;
513 boost::mt19937 rng_alg_;
518 boost::shared_ptr<boost::variate_generator<boost::mt19937&,
519 boost::uniform_real<float> >
520 > rng_uniform_distribution_;
523 std::string getClassName ()
const {
return (
"MovingLeastSquares"); }
526 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
536 template <
typename Po
intInT,
typename Po
intOutT>
537 class MovingLeastSquaresOMP:
public MovingLeastSquares<PointInT, PointOutT>
540 typedef boost::shared_ptr<MovingLeastSquares<PointInT, PointOutT> > Ptr;
541 typedef boost::shared_ptr<const MovingLeastSquares<PointInT, PointOutT> > ConstPtr;
545 using MovingLeastSquares<PointInT, PointOutT>::normals_;
546 using MovingLeastSquares<PointInT, PointOutT>::corresponding_input_indices_;
547 using MovingLeastSquares<PointInT, PointOutT>::nr_coeff_;
548 using MovingLeastSquares<PointInT, PointOutT>::order_;
549 using MovingLeastSquares<PointInT, PointOutT>::compute_normals_;
555 typedef typename PointCloudOut::Ptr PointCloudOutPtr;
556 typedef typename PointCloudOut::ConstPtr PointCloudOutConstPtr;
561 MovingLeastSquaresOMP (
unsigned int threads = 0) : threads_ (threads)
570 setNumberOfThreads (
unsigned int threads = 0)
579 virtual void performProcessing (PointCloudOut &output);
582 unsigned int threads_;
587 #ifdef PCL_NO_PRECOMPILE
588 #include <pcl/surface/impl/mls.hpp>
PointCloudOut::ConstPtr PointCloudOutConstPtr
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.
KdTreePtr tree_
A pointer to the spatial search object.
void setPolynomialOrder(int order)
Set the order of the polynomial to be fit.
virtual void performProcessing(PointCloudOut &output)
Abstract surface reconstruction method.
virtual ~MovingLeastSquares()
Empty destructor.
PointCloudIn::Ptr PointCloudInPtr
KdTreePtr getSearchMethod()
Get a pointer to the search method used.
float voxel_size_
Voxel size for the VOXEL_GRID_DILATION upsampling method.
pcl::search::Search< PointInT > KdTree
void setUpsamplingRadius(double radius)
Set the radius of the circle in the local point plane that will be sampled.
void performUpsampling(PointCloudOut &output)
Perform upsampling for the distinct-cloud and voxel-grid methods.
void setPointDensity(int desired_num_points_in_radius)
Set the parameter that specifies the desired number of points within the search radius.
boost::shared_ptr< MovingLeastSquares< PointInT, PointOutT > > Ptr
PointCloudInConstPtr getDistinctCloud()
Get the distinct cloud used for the DISTINCT_CLOUD upsampling method.
void getCellIndex(const Eigen::Vector3f &p, Eigen::Vector3i &index) const
void setComputeNormals(bool compute_normals)
Set whether the algorithm should also store the normals computed.
int getDilationIterations()
Get the number of dilation steps of the voxel grid.
PointCloudOut::Ptr PointCloudOutPtr
pcl::PointCloud< PointInT > PointCloudIn
Data structure used to store the results of the MLS fitting.
pcl::PointCloud< pcl::Normal >::Ptr NormalCloudPtr
void setSearchMethod(const KdTreePtr &tree)
Provide a pointer to the search object.
double upsampling_step_
Step size for the local plane sampling.
void copyMissingFields(const PointInT &point_in, PointOutT &point_out) const
int nr_coeff_
Number of coefficients, to be computed from the requested order.
void setDilationIterations(int iterations)
Set the number of dilation steps of the voxel grid.
int desired_num_points_in_radius_
Parameter that specifies the desired number of points within the search radius.
bool polynomial_fit_
True if the surface and normal be approximated using a polynomial, false if tangent estimation is suf...
NormalCloudPtr normals_
The point cloud that will hold the estimated normals, if set.
void setUpsamplingStepSize(double step_size)
Set the step size for the local plane sampling.
double upsampling_radius_
Radius of the circle in the local point plane that will be sampled.
CloudSurfaceProcessing represents the base class for algorithms that takes a point cloud as input and...
Eigen::Vector3d plane_normal
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
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.
int getPolynomialOrder()
Get the order of the polynomial to be fit.
void setSearchRadius(double radius)
Set the sphere radius that is to be used for determining the k-nearest neighbors used for fitting...
boost::shared_ptr< PointCloud< PointT > > Ptr
Eigen::Vector4f bounding_min_
bool getPolynomialFit()
Get the polynomial_fit value (true if the surface and normal are approximated using a polynomial)...
void getPosition(const uint64_t &index_1d, Eigen::Vector3f &point) const
A point structure representing normal coordinates and the surface curvature estimate.
MLSVoxelGrid(PointCloudInConstPtr &cloud, IndicesPtr &indices, float voxel_size)
double getSearchRadius()
Get the sphere radius used for determining the k-nearest neighbors.
PointIndicesPtr getCorrespondingIndices()
Get the set of indices with each point in output having the corresponding point in input...
boost::shared_ptr< std::vector< int > > IndicesPtr
SearchMethod search_method_
The search method template for indices.
float getDilationVoxelSize()
Get the voxel size for the voxel grid.
Eigen::Vector4f bounding_max_
PointIndicesPtr corresponding_input_indices_
Collects for each point in output the corrseponding point in the input.
PointCloudInConstPtr distinct_cloud_
The distinct point cloud that will be projected to the MLS surface.
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...
boost::shared_ptr< const MovingLeastSquares< PointInT, PointOutT > > ConstPtr
IndicesPtr indices_
A pointer to the vector of point indices to use.
bool compute_normals_
Parameter that specifies whether the normals should be computed for the input cloud or not...
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
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.
UpsamplingMethod upsample_method_
Parameter that specifies the upsampling method to be used.
int order_
The order of the polynomial to be fit.
double getUpsamplingStepSize()
Get the step size for the local plane sampling.
pcl::PointCloud< PointOutT > PointCloudOut
void setPolynomialFit(bool polynomial_fit)
Sets whether the surface and normal are approximated using a polynomial, or only via tangent estimati...
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.
void setUpsamplingMethod(UpsamplingMethod method)
Set the upsampling method to be used.
void setSqrGaussParam(double sqr_gauss_param)
Set the parameter used for distance based weighting of neighbors (the square of the search radius wor...
MovingLeastSquares()
Empty constructor.
MovingLeastSquares represent an implementation of the MLS (Moving Least Squares) algorithm for data s...
pcl::PointCloud< pcl::Normal > NormalCloud
boost::shared_ptr< ::pcl::PointIndices > PointIndicesPtr
double getUpsamplingRadius()
Get the radius of the circle in the local point plane that will be sampled.
double sqr_gauss_param_
Parameter for distance based weighting of neighbors (search_radius_ * search_radius_ works fine) ...
boost::shared_ptr< PointIndices > PointIndicesPtr
pcl::search::Search< PointInT >::Ptr KdTreePtr
void setDilationVoxelSize(float voxel_size)
Set the voxel size for the voxel grid.
void getIndexIn3D(uint64_t index_1d, Eigen::Vector3i &index_3d) const
PointCloudConstPtr input_
The input point cloud dataset.
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.
A minimalistic implementation of a voxel grid, necessary for the point cloud upsampling.
double getSqrGaussParam() const
Get the parameter for distance based weighting of neighbors.
PointCloudIn::ConstPtr PointCloudInConstPtr
std::vector< MLSResult > mls_results_
Stores the MLS result for each point in the input cloud.
boost::function< int(int, double, std::vector< int > &, std::vector< float > &)> SearchMethod
int dilation_iteration_num_
Number of dilation steps for the VOXEL_GRID_DILATION upsampling method.
void getIndexIn1D(const Eigen::Vector3i &index, uint64_t &index_1d) const
std::map< uint64_t, Leaf > HashMap