【双目视觉】PCL函数库摘要——点云曲面重建

目录

1.PCL点云曲面重建 API

1.Class pcl::ConcaveHull< PointInT >

2.Class pcl::ConvexHull< PointInT >

3.Class pcl::EarClipping

4.Class pcl::GreedyProjectionTriangulation< PointInT >

5.Class pcl::GridProjection< PointNT >

6.Class pcl::MarchingCubes< PointNT >

7.Class pcl: :MarchingCubesGreedy

8.Class pcl::MovingLeastSquares< PointInT, PointOutT >

9.Class pcl: : MovingLeastSquaresOMP < PointInT,PointOutT>

10.Class pcl::OrganizedFastMesh< PointInT > Class

11.Class pcl::Poisson< PointNT >

12.Class pcl::CloudSurfaceProcessing< PointInT, PointOutT >

13.Class pcl::MeshProcessing

14.Class pcl::SurfaceReconstruction< PointInT >

15.Class pcl::MeshConstruction< PointInT >

16.Class pcl::TextureMapping< PointInT >

17.surface 模块中其他关键成员说明

2.参考实例 

2.1. 曲面重建-三角法

2.1.1. 实现效果

​2.1.2. github源码

2.1.3.参考出处

2.2. 曲面重建-泊松曲面重建(PclSharp)

2.1.1. 实现效果

2.1.3.参考出处


1.PCL点云曲面重建 API

        PCL库种surface模块是用来对三维扫描获取的原始点云进行曲面重建的,该模块包含实现点云重建的基础算法与数据结构。

1.Class pcl::ConcaveHull< PointInT >

        类ConcaveHull实现了创建凹多边形的算法,该类的实现其实是Hull库实现的接口封装,ConcaveHull支持二维和三维点集。

#include <pcl/surface/concave_hull.h>
ConcaveHull () 
//  空构造函数
virtual  ~ConcaveHull () 
//  空析构函数
void  setSearchMethod (const KdTreePtr &tree) 
//  设置搜索时所用的搜索机制,参数tree指向搜索时所用的搜索对象,例如kd-tree、octree等对象。 
virtual void  setInputCloud (const PointCloudConstPtr &cloud) 
//  设置输入点云,参数cloud 为输入点云的共享指针引用。
virtual void  setIndices (const IndicesPtr &indices) 
//  为输入点云提供点云索引向量的指针。
virtual void  setIndices (const IndicesConstPtr &indices) 
//  为输入点云提供点云索引向量的指针,该索引为常数,不能更改。
virtual void  setIndices (const PointIndicesConstPtr &indices) 
//  为输入点云提供点云不变索引向量指针的指针。
virtual void  setIndices (size_t row_start, size_t col_start, size_t nb_rows, size_t nb_cols) 
//  为输入点云中要用到的部分提供索引,该方法只能用于有序点云。参数row_start为行偏移、col_start为列偏移、nb_rows表示 row_start进行的行偏移数,nb_cols表示进行的列偏移数。
void  reconstruct (PointCloud &points, std::vector< pcl::Vertices > &polygons) 
//  计算所有输入点的凹多边形,参数 points存储最终产生的凹多边形上的顶点,参数 polygons存储一系列顶点集,每个顶点集构成的一个多边形,Vertices数据结构包含一组点的索引,索引是point中的点对应的索引。
void  reconstruct (PointCloud &output) 
//  计算所有输入点的凹多边形﹐输出的维数取决于输入的维数是二维或三维,输出结果为多边形顶点并存储在参数output中。
void  setAlpha (double alpha) 
//  设置alpha值,参数alpha限制voronoi图中多边形边长的长短(边长越短多边形越细分),alpha值是一个非零的正值,定义了voronoi图中多边形顶点到中心点的最大距离。
double  getAlpha () 
//  获取alpha值
void  setVoronoiCenters (PointCloudPtr voronoi_centers) 
//  设置参数voronoi_centers,如果设置,最终产生的凹多边形对应的voronoi图中的多边形的中心将被存储在参数voronoi_centers中。
void  setKeepInformation (bool value) 
//  设置参数keep_information,如果keep_information为真,凹多边形中的顶点就保留其他信息,如 RGB值、法线等。
int  getDim () const 
//  返回计算得到多边形的维数(二维或三维)。
int  getDimension () const 
//  返回计算得到多边形的维数(二维或三维)。
void  setDimension (int dimension) 
//  设置输入数据的维数(二维或三维),参数dimension为设置输入数据的维度﹐如果没有设置,输入数据的维度将自动根据输入点云设置。
void  getHullPointIndices (pcl::PointIndices &hull_point_indices) const 
//  检索凸包的输入点云的索引。

2.Class pcl::ConvexHull< PointInT >

        类ConvexHull实现了创建凸多边形的算法,该类的实现其实是Hull库实现的接口封装,ConcvexHull支持二维和三维点集。

#include <pcl/surface/convex_hull.h>
ConvexHull () 
//  空构造函数
virtual  ~ConvexHull () 
//  空析构函数
void  reconstruct (PointCloud &points, std::vector< pcl::Vertices > &polygons) 
//  计算所有输入点的凹多边形,参数 points存储最终产生的凹多边形上的顶点,参数 polygons存储一系列顶点集,每个顶点集构成的一个多边形,Vertices数据结构包含一组点的索引,索引是point中的点对应的索引。
void  reconstruct (PointCloud &points) 
//  计算所有输入点的凹多边形﹐输出的维数取决于输入的维数是二维或三维,输出结果为多边形顶点并存储在参数output中。
void  setComputeAreaVolume (bool value) 
//  是否计算凸多边形的面积和体积,如果参数value为真,调用qhull库计算凸多边形的总面积和总体积。为节省计算资源,参数value缺省值为false。
double  getTotalArea () const 
//  获取凸包的总面积,如果 setComputeAreaVolume设置为真时,才会有有效输出。
double  getTotalVolume () const 
//  获取凸包的总体积,如果 setComputeAreaVolume设置为真时,才会有有效输出。
void  setDimension (int dimension) 
//  设置输入数据的维数(二维或三维),参数dimension为设置输入数据的维度﹐如果没有设置,输入数据的维度将自动根据输入点云设置。
int  getDimension () const 
//  返回计算得到多边形的维数(二维或三维)。
void  getHullPointIndices (pcl::PointIndices &hull_point_indices) const 
//  检索凸包的输入点云的索引。


3.Class pcl::EarClipping

        类EarClipping实现了对多边形进行三角化的EarClipping算法,其输入为多边形网格模型数据,输出为三角化后的精细网格模型。

#include <pcl/surface/ear_clipping.h>
EarClipping () 
//  空构造函数
void  setInputMesh (const pcl::PolygonMeshConstPtr &input) 
//  设置输入网格模型数据,input指向多边形网格的指针引用。
pcl::PolygonMeshConstPtr  getInputMesh () const 
//  获取输入网格模型数据
void  process (pcl::PolygonMesh &output) 
//  三角化处理输入的多边形网格数据并将处理得到的精细曲面模型存储到out-

4.Class pcl::GreedyProjectionTriangulation< PointInT >

        类GreedyProjectionTriangulation实现了将三维点投影到某一局部二维坐标平面的贪婪三角化算法,该算法需要点云平滑,并且密度变化连续。

#include <pcl/surface/gp3.h>
GreedyProjectionTriangulation () 
//  空构造函数
void  setMu (double mu) 
//  设置样本点到最近邻域距离的乘积系数mu来获得每个样本点的最大搜索距离,这样使得算法自适应点云密度的变化。
double  getMu () const 
//  获取样本点到最近邻域距离的乘积系数mu
void  setMaximumNearestNeighbors (int nnn) 
//  设置样本点最多可以搜索的邻域数目nnn。
int  getMaximumNearestNeighbors () const 
//  获取样本点最多可以搜索的邻域数目。
void  setSearchRadius (double radius) 
//  设置搜索半径radius,来确定三角化时k-邻近的球半径。
double  getSearchRadius () const 
//  获取搜索半径,即三角化时k-邻近的球半径。
void  setMinimumAngle (double minimum_angle) 
//  设置三角化后三角形的最小角,参数minimum_angle为最小角的值。
double  getMinimumAngle () const 
//  获取三角化后三角形的最小角。
void  setMaximumAngle (double maximum_angle) 
//  设置三角化后三角形的最大角,参数maximum_angle为最大角的值。
double  getMaximumAngle () const 
//  获取三角化后三角形的最大角。
void  setMaximumSurfaceAngle (double eps_angle) 
//  设置连接时的最大角度eps_ angle, 当某点法线相对于采样点的法线偏离角度超过该最大角度时,连接时就不考虑该点。
double  getMaximumSurfaceAngle () const 
//  设置连接时的最大角度
void  setNormalConsistency (bool consistent) 
//  设置一个标志consistent,来保证法线朝向一致,如果设置为true则会使得算法保持法线方向一致,如果为false 算法则不会进行法线一致性检查。
bool  getNormalConsistency () const 
//  获取是否保证法线朝向一致的标志。
void  setConsistentVertexOrdering (bool consistent_ordering) 
//  设置一个标志consistent_ordering 来使三角形顶点次序一致(围绕法线正方向),注:在这里假设法线朝向一致(都朝向观测点)。参数consistent_ordering 为真,三角形顶点排序方式一致。
bool  getConsistentVertexOrdering () const 
//  获取使三角形顶点次序一致(围绕法线正方向)的标志。
std::vector< int >  getPointStates () const 
//  获得重建后每点的状态,取值为FREE、FRINGE、BOUNDARY、COMPLETED、NONE常量,其中NONE表示未定义,FREE表示该点没有在三角化后的拓扑内,为自由点,COMPLETED表示该点在三角化后的拓扑内,并且邻域都有拓扑点,BOUNDARY表示该点在三角化后的拓扑边缘,FRINGE表示该点在三角化后的拓扑内,其连接会产生重叠边。
std::vector< int >  getPartIDs () const 
//  获得重建后每点的ID,Parts从0开始编号,a-1表示未连接的点。
std::vector< int >  getSFN () const 
//  获得SFN表
std::vector< int >  getFFN () const 
//  获得FFN表

5.Class pcl::GridProjection< PointNT >

        类GridProjection实现了网格投影曲面重建算法,详细信息参考Polygonizingextremal surfaces with manifold guarantees 。

#include <pcl/surface/grid_projection.h>
GridProjection () 
//  构造函数
GridProjection (double in_resolution) 
//  构造函数
~GridProjection () 
//  析构函数
void  setResolution (double resolution) 
//  设置投影网格的大小。
double  getResolution () const 
//  获取投影网格的大小。
void  setPaddingSize (int padding_size) 
//  设置处理查询点时所用的填充区域(Paddingsize)大小,在进行矢量平均计算时,找出包括填充区域的所有输入数据点,然后做加权平均作为矢量平均输出。例如:填充区域大小是1的话,当我们处理网格单元(x,y,z)时,将数据点从(x-1)~(x+1),(y-1)~(y+1),(z-1)~(z+1)(总共27个网格单元的集合)作为填充区域。这种方式下,即使网格单元自己不包含任何数据点,算法仍能进行处理,因为填充区域内有数据点,这样可以帮助修补比填充区域小的孔洞。
int  getPaddingSize () const 
//  获取处理查询点时所用的填充区域(Paddingsize)大小。
void  setNearestNeighborNum (int k) 
//  仅在使用K近邻搜索点集时,才采用此函数设置k,k为搜索的最近邻域的数目。
int  getNearestNeighborNum () const 
//  获取使用K近邻搜索点集时的搜索最近邻域的数目。
void  setMaxBinarySearchLevel (int max_binary_search_level) 
//  将二分搜索法用于投影,给出一个点X,找到另一个离点X有3个网格单元远的点,然后在这两点之间进行二分搜索,确定投影点的位置, max_ binary_search_level设置二分的水平。
int  getMaxBinarySearchLevel () const 
//  获取二分搜索法的二分水平
const HashMap &  getCellHashMap () const 
//  获取投影单元的hash映射表,返回值类型为HashMap。
const std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > &  getVectorAtDataPoint () const 
  
const std::vector< Eigen::Vector4f, Eigen::aligned_allocator< Eigen::Vector4f > > &  getSurface () const 



6.Class pcl::MarchingCubes< PointNT >

        类MarchingCubes实现了基于点云的移动立方体曲面重建算法,该算法为最常用的CT切片等值面提取方法,PCL将其调整为适用于点云的曲面重建。

#include <pcl/surface/marching_cubes.h>
MarchingCubes () 
//  构造函数
virtual  ~MarchingCubes () 
//  析构函数
void  setIsoLevel (float iso_level) 
//  设置等值面提取时所使用的水平值。
float  getIsoLevel () 
//  获取等值面提取时所使用的水平值。
void  setGridResolution (int res_x, int res_y, int res_z) 
//  设置移动立方体网格分辨率。
void  getGridResolution (int &res_x, int &res_y, int &res_z) 
//  获取移动立方体网格分辨率。
void  setPercentageExtendGrid (float percentage) 
//  设置参数percentage,该参数定义在点云边界框和栅格限制之间的栅格内应剩余多少可用空间。
float  getPercentageExtendGrid () 
//  设置参数,该参数定义在点云边界框和栅格限制之间的栅格内应剩余多少可用空间。


7.Class pcl: :MarchingCubesGreedy

        类MarchingCubesGreedy在实现对点云所在三维空间平均单元格空间划分过程中用贪婪移动立方体算法,该类的关键成员函数接口参照类MarchingCubes。

8.Class pcl::MovingLeastSquares< PointInT, PointOutT >

        类MovingLeastSquares实现了基于移动最小二乘算法的点云平滑处理、数据重采样,并且可以计算优化的估计法线,其输入是点云数据,输出为经过用户设定参数对应的处理之后得到的平滑重采样点云。

#include <pcl/surface/mls.h>
MovingLeastSquares () 
//  空构造函数
virtual  ~MovingLeastSquares () 
//  空析构函数
void  setComputeNormals (bool compute_normals) 
//  设置是否计算并存储点云对应的法线,参数compute_normals为true则设置为是。
void  setSearchMethod (const KdTreePtr &tree) 
//  设置搜索时所用的搜索机制,参数tree指向搜索时所用的搜索对象,例如kd-tree、octree等对象。
KdTreePtr  getSearchMethod () 
//  获取指向搜索时所用的搜索对象的指针。
void  setPolynomialOrder (int order) 
//  设置使用多项式拟合进行运算时所用的阶数order。
int  getPolynomialOrder () 
//  获取使用多项式拟合进行运算时所用的阶数。
void  setPolynomialFit (bool polynomial_fit) 
//  设置在进行估计法线时是否使用多项式拟合进行逼近,还是仅通过切线估计得到, polynomial_fit 参数为true则设置为是。
bool  getPolynomialFit () 
//  获取在进行估计法线时是否使用多项式拟合进行逼近,还是仅通过切线估计得到。
void  setSearchRadius (double radius) 
//  设置搜索半径radius,确定多项式拟合时所用的邻域点进行k近邻搜索时所用的半径。
double  getSearchRadius () 
//  获取搜索半径。
void  setSqrGaussParam (double sqr_gauss_param) 
//  设置近邻高斯权重系数sqr_gauss_param,一般设置成搜索半径的平方时效果最好。
double  getSqrGaussParam () const 
//  获取近邻高斯权重系数sqr_gauss_param。
void  setUpsamplingMethod (UpsamplingMethod method) 
//  设置上采样算法method,共提供4种方式:
/*
(1) NONE:不进行上采样,直接将原始点投影到由最小二乘拟合出的曲面,得到采样后的点。
(2) SAMPLE LOCAL_PLANE: 按照设置好的参数上采样半径(upsampling_radius)和参数上采样迭代步数(upsampling_step),在定义出的平面局部邻域内画圆,再将圆投影到拟合曲面上,再进行离散采样,得到采样后的点。
(3) RANDOM_UNIFORM_DENSITY: 在定义出的平面局部邻域内,按设置好的点密度均匀取点,再将其投影到拟合曲面上,得到采样点。
(4) VOXEL_GRID_DILATION:通过设置参数体素大小( voxel_size)将原始点云所在空间进行体素化处理,再通过设置参数体素膨胀次数(dilation_iteration_num)对体素进行膨胀,膨胀过程中将没有点云的栅格体素中也填充上点云,最后得到采样后的点。
*/
void  setDistinctCloud (PointCloudInConstPtr distinct_cloud) 
//  设置用于DISTINCT_CLOUD上采样方法的不同云。Set the distinct cloud used for the DISTINCT_CLOUD upsampling method. More...  
PointCloudInConstPtr  getDistinctCloud () 
//  获取用于DISTINCT_CLOUD上采样方法的不同云。Set the distinct cloud used for the DISTINCT_CLOUD upsampling method. More... 
void  setUpsamplingRadius (double radius) 
//  设置上采样半径radius,用于SAMPLE_LOCAL_PLANE。
double  getUpsamplingRadius () 
//  获取上采样半径radius。
void  setUpsamplingStepSize (double step_size) 
//  设置上采样迭代次数step_size,用 于SAMPLE_LOCAL_PLANE.
double  getUpsamplingStepSize () 
//  获取上采样迭代次数step_size。
void  setPointDensity (int desired_num_points_in_radius) 
//  设置点的采样密度desired_num_points_in_radius, 用于RANDOM_UNIFORM_DENSITY。
int  getPointDensity () 
//  设置点的采样密度desired_num_points_in_radius。
void  setDilationVoxelSize (float voxel_size) 
//  设置体素的大小voxel_size, 用于VOXEL_GRID_ DILATION。
float  getDilationVoxelSize () 
//  获取体素的大小voxel_size。
void  setDilationIterations (int iterations) 
//  设置体素膨胀次数iterations,用于VOXEL_GRID_DILATION。
int  getDilationIterations () 
//  获取体素膨胀次数iterations
void  process (PointCloudOut &output) 
//  对所有输入点云进行基于最小二乘法算法的曲面重建,输出结果为曲面模型并存储在output中。
PointIndicesPtr  getCorrespondingIndices () 
//  得到一组索引,其中输出中的每个点在输入中都有相应的点。Get the set of indices with each point in output having the corresponding point in input. More... 



9.Class pcl: : MovingLeastSquaresOMP < PointInT,PointOutT>

        类MovingLeastSquaresOMP是类MovingLeastSquares 基于OpenMP的实现并行高速处理,其关键成员函数参照类MovingLeastSquares。

10.Class pcl::OrganizedFastMesh< PointInT > Class

        类OrganizedFastMesh实现了对有序点云的快速多边形网格化,该类只是针对有序点云而实现的快速曲面重建,输入为有序点云,输出为曲面模型。

#include <pcl/surface/organized_fast_mesh.h>
OrganizedFastMesh () 
//  构造函数
virtual  ~OrganizedFastMesh () 
//  析构函数
void  setMaxEdgeLength (float a, float b=0.0f, float c=0.0f) 
//  设置生成曲面模型中多边形的最大边长为threshold(x) = c*x*x + b*x + a。
void  unsetMaxEdgeLength () 
  
void  setTrianglePixelSize (int triangle_size) 
//  对于重建固定三角形大小的曲面模型,设置三角形边长为triangle_size,单位为像素,例如triangle_size=1,就连接相邻点作为边长,也为默认值。
void  setTrianglePixelSizeRows (int triangle_size) 
//  对于重建固定三角形大小的曲面模型,设置行方向的三角形边长为triangle_size,单位为像素,例如triangle_size=1,就连接相邻点作为边长,也为默认值。Set the edge length (in pixels) used for iterating over rows when constructing the fixed mesh. More...  
void  setTrianglePixelSizeColumns (int triangle_size) 
//  对于重建固定三角形大小的曲面模型,设置列方向的三角形边长为triangle_size,单位为像素,例如triangle_size=1,就连接相邻点作为边长,也为默认值。Set the edge length (in pixels) used for iterating over columns when constructing the fixed mesh. More...
void  setTriangulationType (TriangulationType type) 
//  设置多边形网格化的类型type,共有4种:四边形网格,即为建立一个简单四边形,最终的曲面模型由四边形组成;三角网格中的triangle right cut,按照从目标点左上角点到右下角点的连接方式;三角网格中的triangle left cut按照从目标点右上角点到左下角点的连接方式;三角网格中的triangle adaptive cut从任意点开始将四边形从对角线连接分开,一般连接z坐标差值大的两个对焦点形成对角线的边。
void  setViewpoint (const Eigen::Vector3f &viewpoint) 
// 设置输入点云的视点。
const Eigen::Vector3f &  getViewpoint () const 
//  获取输入点云的视点。
void  storeShadowedFaces (bool enable) 
//  设置是否存储阴影面,enable为true时,设置存储阴影面。
void  setAngleTolerance (float angle_tolerance) 
//  设置用于检查边是否被遮挡的角度公差Set the angle tolerance used for checking whether or not an edge is occluded. More...  
void  setDistanceTolerance (float distance_tolerance, bool depth_dependent=false) 
  
void  useDepthAsDistance (bool enable) 
//  设置使用点的深度(z坐标),而不是测量的距离(点到视点的距离)。Use the points' depths (z-coordinates) instead of measured distances (points' distances to the viewpoint). More... 



11.Class pcl::Poisson< PointNT >

        类Poisson是对泊松曲面重建算法的实现,输入是带有法线的点云,输出为重建后的曲面模型数据,泊松曲面重建的实现是基于文献Poisson surface reconstruction。

#include <pcl/surface/poisson.h>
Poisson () 
//  将所有参数设置为有效默认值的构造函数
~Poisson () 
//  析构函数
void  performReconstruction (pcl::PolygonMesh &output) 
//  进行曲面泊松重建,输出结果为多边形网格曲面模型并存储在参数output中。
void  performReconstruction (pcl::PointCloud< PointNT > &points, std::vector< pcl::Vertices > &polygons) 
//  进行泊松曲面重建,参数points存储重建所得的多边形的顶点点云,参数polygons为重建所得多边形曲面模型,它是通过顶点索引方式表示每个多边形的。
void  setDepth (int depth) 
//  设置在重建算法中用到的八叉树的最大深度,该值只是个上限,因为在算法中八叉树的深度是根据点云的密度自适应的。
int  getDepth () 
//  获取在重建算法中用到的八叉树的最大深度,该值只是个上限,因为在算法中八叉树的深度是根据点云的密度自适应的。
void  setMinDepth (int min_depth) 
  
int  getMinDepth () 
  
void  setPointWeight (float point_weight) 
  
float  getPointWeight () 
  
void  setScale (float scale) 
//  设置尺度参数scale,该参数为用来进行重建的立方体体素对应的直径与采样时的立方体直径之比。
float  getScale () 
//  获取用来进行重建的立方体体素对应的直径与采样时的立方体直径之比。
void  setSolverDivide (int solver_divide) 
//  设置参数solver_divide,该参数是在算法中求解拉普拉斯等式时所用的高斯赛德尔算法的深度。
int  getSolverDivide () 
//  获取在算法中求解拉普拉斯等式时所用的高斯赛德尔算法的深度。
void  setIsoDivide (int iso_divide) 
//  设置等值面提取时的深度的参数iso_divide,设置该值可以避免重建时有可能的内存溢出,当然重建时间有少量增加,经过试验,该值设置为9或更高时,内存使用量减少很明显,平时使用7或8比较合适。
int  getIsoDivide () 
//  获取等值面提取时的深度的参数
void  setSamplesPerNode (float samples_per_node) 
//  设置每个八叉树节点上最少采样点数目samples_per_node, 原因是八叉树的建立是与点云密度自适应调节的,所以需要设置最小数目。在应用当中,当采样点噪声比较小的时候,该值可以设置的比较小[1.0~5.0],当采样点噪声较大的时候,就要选用较大值的范围[15.0~20.0],这样有利于最终得到平滑无噪声的曲面重建。
float  getSamplesPerNode () 
//  获取每个八叉树节点上最少采样点数目。  
void  setConfidence (bool confidence) 
//  设置一个置信度标志,confidence为true时,设定重建算法使用法线向量长度作为置信度信息,如果confidence为false,则在重建之前,对法线进行归一化处理。
bool  getConfidence () 
//  获取置信度标志。
void  setOutputPolygons (bool output_polygons) 
//  设置是否输出为多边形,如果output_polygons设置为true,则重建输出为多边形,否则,输出为三角化后的曲面模型。
bool  getOutputPolygons () 
//  获取是否输出为多边形的布尔值。
void  setDegree (int degree) 
//  设置函数阶数degree,参数degree为一个给定的阶数。
int  getDegree () 
//  获取函数阶数。
void  setManifold (bool manifold) 
//  设置流行标志mainfold,如果设置为true,则在对多边形进行细分三角化时添加重心,设置为false则不添加。
bool  getManifold () 
//  获取流行标志mainfold。



12.Class pcl::CloudSurfaceProcessing< PointInT, PointOutT >

        类CloudSurfaceProcessing是类MovingLeastSquares的基类。

#include <pcl/surface/processing.h>

13.Class pcl::MeshProcessing

        类pcl:: MeshProcessing是类EarClipping 的基类。

#include <pcl/surface/processing.h>

14.Class pcl::SurfaceReconstruction< PointInT >

        类SurfaceReconstruction是类Poisson、类GridProjection 和类MarchingCubes的基类。

#include <pcl/surface/reconstruction.h>
SurfaceReconstruction () 
//  构造函数
virtual  ~SurfaceReconstruction () 
//  析构函数
virtual void  reconstruct (pcl::PolygonMesh &output) 
//  对所有输入点云进行曲面重建,输出结果为多边形网格曲面模型并存储在参数output中。
virtual void  reconstruct (pcl::PointCloud< PointInT > &points, std::vector< pcl::Vertices > &polygons) 
//  对所有输入点进行曲面重建,参数points 存储重建后曲面上的点,参数polygons存储一系列顶点集构成的多边形,Vertices数据结构包含一队列的点的索引。
virtual void  setInputCloud (const PointCloudConstPtr &cloud) 
//  设置输入点云,参数cloud为输入点云的共享指针引用


15.Class pcl::MeshConstruction< PointInT >

        类SurfaceReconstruction是类ConvexHull.类ConcaveHull、类GreedyProjectionTriangulation和类OrganizedFastMesh的基类。

#include <pcl/surface/reconstruction.h>
MeshConstruction () 
//  构造函数
virtual  ~MeshConstruction () 
//  析构函数
virtual void  reconstruct (pcl::PolygonMesh &output) 
//  对所有输入,点进行曲面重建,输出结果为多边形网格曲面模型并存储在参数output中。
virtual void  reconstruct (std::vector< pcl::Vertices > &polygons) 
//  对所有输入点进行曲面重建,参数polygons存储一系列顶点集构成的多边形,Vertices数据结构包含一队列的点的索引。
virtual void  setInputCloud (const PointCloudConstPtr &cloud) 
//  设置输入点云,参数cloud为输入点云的共享指针引用。


16.Class pcl::TextureMapping< PointInT >

        类TextureMapping实现了纹理映射算法,实现对输入曲面模型和纹理模型的映射或贴图。

#include <pcl/surface/texture_mapping.h>
TextureMapping () 
//  构造函数
~TextureMapping () 
//  析构函数
void  setF (float f) 
//  设置网格模型缩放系数。
void  setVectorField (float x, float y, float z) 
//  设置向量场。
void  setTextureFiles (std::vector< std::string > tex_files) 
//  设置在进行纹理映射时所需要的纹理文件,tex_files为一系列的纹理文件。
void  setTextureMaterials (TexMaterial tex_material) 
//  设置在纹理映射时所需的材质,tex_material为材质对象。
void  mapTexture2Mesh (pcl::TextureMesh &tex_mesh) 
//  将设置好的纹理映射到网格模型tex_mesh中去。
void  mapTexture2MeshUV (pcl::TextureMesh &tex_mesh) 
//  将设置好的纹理通过UV纹理坐标映射到网格模型中去。
void  mapMultipleTexturesToMeshUV (pcl::TextureMesh &tex_mesh, pcl::texture_mapping::CameraVector &cams) 
//  映射从摄像机cams获取的纹理到指定的tex_mesh中。
bool  getPointUVCoordinates (const PointInT &pt, const Camera &cam, Eigen::Vector2f &UV_coordinates) 
//  从摄像机cam观察点pt,获取UV坐标存储在UV_coordinates中,如果成功返回true。
bool  isPointOccluded (const PointInT &pt, const OctreePtr octree) 
//  利用光线跟踪法检测点判断pt是否被其他点遮挡,pt为光线起始点,光线射向摄像机,其中octree是设置在光线跟踪时所用的八叉树对象,要求它必须用点云数据初始化过,并且转化为摄像机坐标系系统。
void  removeOccludedPoints (const PointCloudPtr &input_cloud, PointCloudPtr &filtered_cloud, const double octree_voxel_size, std::vector< int > &visible_indices, std::vector< int > &occluded_indices) 
//  删除遮挡点,其中参数input_cloud为需要进行遮挡检测的点云对象指针引用,filtered_cloud存储删除遮挡后的点云对象指针引用,octree_voxel_size设置在进行遮挡检测时所建立的八叉树的体素大小,单位为m,visible_indices存储可见的点云索引向量,occluded_indices存储遮挡住的点云索引向量。
void  removeOccludedPoints (const pcl::TextureMesh &tex_mesh, pcl::TextureMesh &cleaned_mesh, const double octree_voxel_size) 
//  功能同上函数,其中参数tex_mesh为需要进行遮挡检测的输入网格,cleaned_mesh为生成的仅包含可见点的网格,octree_voxel_size为八叉树分辨率。  
void  removeOccludedPoints (const pcl::TextureMesh &tex_mesh, PointCloudPtr &filtered_cloud, const double octree_voxel_size) 
//  功能同上函数,其中参数tex_mesh为需要进行遮挡检测的输入网格,filtered_cloud为生成的仅包含可见点的点云,octree_voxel_size为八叉树分辨率。    
int  sortFacesByCamera (pcl::TextureMesh &tex_mesh, pcl::TextureMesh &sorted_mesh, const pcl::texture_mapping::CameraVector &cameras, const double octree_voxel_size, PointCloud &visible_pts) 
//  通过摄像机对曲面模型进行分割,其中参数tex_mesh为需要分割的曲面模型,必须是单一的一个曲面模型,sorted_mesh存储通过摄像机对曲面模型进行分割后的N+1个曲面模型,N是摄像头的个数,多余的一个曲面模型是摄像头观察不到的剩余曲面部分,cameras存储N个摄像头,octree_voxel_size设置内部计算时所用到的八叉树体素大小,单位米,visible_pts 存储可以观察到的点的集合组成的点云对象。
void  showOcclusions (const PointCloudPtr &input_cloud, pcl::PointCloud< pcl::PointXYZI >::Ptr &colored_cloud, const double octree_voxel_size, const bool show_nb_occlusions=true, const int max_occlusions=4) 
//  根据每个点的遮挡程度,对点进行着色,其中input_cloud为进行遮挡计算的输入点云,colored_cloud根据遮挡程度进行颜色赋值之后得到的点云,ctree_voxel_size为在进行计算时所用的八叉树的体素大小,show_nb_occlusions如果设置为true则根据遮挡点数目设置不同的颜色,遮挡点最大数目会归到0~max_occlusions,即遮挡点的最大数目为max_occlusions, 如果show_nb_occlusions 为false, 则只表征点是否被遮挡,不会显示出遮挡数目的信息。
void  showOcclusions (pcl::TextureMesh &tex_mesh, pcl::PointCloud< pcl::PointXYZI >::Ptr &colored_cloud, double octree_voxel_size, bool show_nb_occlusions=true, int max_occlusions=4) 
//  功能同上函数,其中参数tex_mesh为进行遮挡计算的输入网格,colored_cloud根据遮挡程度进行颜色赋值之后得到的点云,ctree_voxel_size为在进行计算时所用的八叉树的体素大小,show_nb_occlusions如果设置为true则根据遮挡点数目设置不同的颜色,遮挡点最大数目会归到0~max_occlusions,即遮挡点的最大数目为max_occlusions, 如果show_nb_occlusions 为false, 则只表征点是否被遮挡,不会显示出遮挡数目的信息。
void  textureMeshwithMultipleCameras (pcl::TextureMesh &mesh, const pcl::texture_mapping::CameraVector &cameras) 
//  通过摄像机对带有纹理的曲面模型进行分割,其中参数mesh为需要分割的曲面模型,必须是单一的一个曲面模型,mesh同时存储通过摄像机对曲面模型进行分到的剩余曲面部分,分割后的曲面模型仍然包含UV信息和纹理,cameras存储N个摄像头。



17.surface 模块中其他关键成员说明

#include <pcl/surface/convex_hull.h>
bool  pcl::comparePoints2D (const std::pair< int, Eigen::Vector4f > &p1, const std::pair< int, Eigen::Vector4f > &p2) 
//  对两个点进行排序,排序规则是将两个点在xy平面上的投影点逆时针与x轴的夹角,如果pl点对应的夹角大于p2点对应的夹角,则返回true,否则返回false。
#include <pcl/surface/gp3.h>
bool  pcl::isVisible (const Eigen::Vector2f &X, const Eigen::Vector2f &S1, const Eigen::Vector2f &S2, const Eigen::Vector2f &R=Eigen::Vector2f::Zero()) 
//  考虑到点s1和点s2间的线段,如果从点R(或者原始点)不能观察到点X,则返回false,其中参数x为该点的二维

2.参考实例 

2.1. 曲面重建-三角法

2.1.1. 实现效果

2.1.2. github源码

Play-with-NVIDIA-Jetson-Nanohttps://link.zhihu.com/?target=https%3A//github.com/doubleZ0108/Play-with-NVIDIA-Jetson-Nano/tree/master/PCL/triangulation

2.1.3.参考出处

PCL库点云可视化与重建实例 - 知乎 (zhihu.com)https://zhuanlan.zhihu.com/p/349304137

2.2. 曲面重建-泊松曲面重建(PclSharp)

2.1.1. 实现效果

2.1.3.参考出处

 (3条消息) PclSharp--泊松曲面重建_pcl泊松重建_西~风的博客-CSDN博客https://blog.csdn.net/swmyaopeng/article/details/126094255

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
PCL(Point Cloud Library)是一个开源的计算机视觉库,其中内置了许多点云处理的算法,包括点云曲面重建点云曲面重建是将无序的点云数据转换为连续的曲面模型,常用于三维建模、机器人视觉导航、医学图像处理等领域。PCL提供了多种点云曲面重建算法,包括基于网格的方法和基于隐式曲面的方法。本文将介绍其中的一种基于网格的方法——Poisson重建。 Poisson重建算法的基本思想是,利用点云数据构建一个无向加权图,并将重建曲面模型视为该图的等势面。在该图上进行拉普拉斯平滑,得到的曲面为最小化拉普拉斯能量的解。 下面是Poisson重建的具体步骤: 1. 对点云进行预处理,去除离群、滤波、下采样等操作,以减少噪声和计算量。 2. 构建点云的法向量估计算法。Poisson重建算法需要法向量信息作为重建的基础,PCL提供了多种法向量估计算法,如基于协方差矩阵的法向量估计、基于法向量的一致性检测等。 3. 构建无向加权图。Poisson重建算法将点云数据视为一个无向加权图,其中每个表示一个顶,每个之间根据一定的规则连接一条边,边权重表示两个之间的相似度。PCL中常用的连接规则为K近邻和半径搜索。 4. 执行Poisson重建算法。在无向加权图上进行拉普拉斯平滑,得到的曲面为最小化拉普拉斯能量的解。Poisson重建算法还可以对结果进行后处理,如光滑、去除孔洞等。 下面是Poisson重建算法的Python实现代码: ``` import pcl # 加载点云数据 cloud = pcl.load('input_cloud.pcd') # 预处理 cloud_filtered = cloud.make_statistical_outlier_filter().filter() cloud_downsampled = cloud_filtered.make_voxel_grid_filter().filter() cloud_normals = cloud_downsampled.make_normal_estimation().compute() # 构建无向加权图 search_tree = cloud_downsampled.make_kdtree() mls = cloud_downsampled.make_moving_least_squares() mls.set_search_radius(0.1) mls.set_polynomial_order(2) mls.set_upsampling_method(pcl.MovingLeastSquares.NONE) cloud_smoothed = mls.process() poisson = cloud_smoothed.make_poisson_reconstruction() poisson.set_depth(9) poisson.set_iso_divide(8) poisson.set_point_weight(4) poisson.set_samples_per_node(1.5) poisson.set_confidence(false) poisson.set_output_polygons(true) reconstructed = poisson.reconstruct() ``` 其中,'input_cloud.pcd'为点云数据文件名,需要先使用PCL进行格式转换。以上代码仅为示例,具体参数需要根据实际应用场景进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

smartvxworks

创造不易,感谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值