pcl曲面点云重建

测量较小的对象时产生一些误差,直接重建会使曲面不光滑或者有漏洞,为了建立完整的模型需要对表面进行平滑处理和漏洞修复.可通过数据重建来解决这一问题,重采样算法通过对周围数据点进行高阶多项式插值来重建表面缺少的部分.

由多个扫描配准后得到的数据直接拿来重建可能产生 "双墙"等重影,即拼接的区域出现重叠的两个曲面,重采样算法可以对此问题进行处理.

pcl库文件中 resampling.cpp代码文件如下:

复制代码
 1 #include <pcl/point_types.h>
 2 #include <pcl/io/pcd_io.h>
 3 #include <pcl/kdtree/kdtree_flann.h>
 4 #include <pcl/surface/mls.h>   //最小二乘平滑处理类定义
 5 
 6 int
 7 main (int argc, char** argv)
 8 {
 9   // Load input file into a PointCloud<T> with an appropriate type
10   pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
11   // Load bun0.pcd -- should be available with the PCL archive in test 
12   pcl::io::loadPCDFile("davi.pcd", *cloud);
13 
14   // Create a KD-Tree
15   pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
16 
17   // Output has the PointNormal type in order to store the normals calculated by MLS
18   pcl::PointCloud<pcl::PointNormal> mls_points;
19 
20   // Init object (second point type is for the normals, even if unused)
21   pcl::MovingLeastSquares<pcl::PointXYZ, pcl::PointNormal> mls;
22   // 设置在最小二乘计算中需要进行法线估计,不需要可跳过
23   mls.setComputeNormals (true);
24 
25   // Set parameters
26   mls.setInputCloud (cloud);
27   mls.setPolynomialFit (true);  //多项式拟合提高精度,可false 加快速度,或选择其他来控制平滑过程
28   mls.setSearchMethod (tree);
29   mls.setSearchRadius (3);
30 
31   // Reconstruct
32   mls.process (mls_points);
33 
34   // Save output
35   pcl::io::savePCDFile ("davi-mls.pcd", mls_points);
36 }
复制代码

 如果法线与处理后原始数据必须在相同PointCloud 对象中,需将这两个字段连接起来形成新的点云.

下图左为原始图,通过20张不同角度的点云拼接而成,左边呈现重影,右图为处理结果图,重影消除.

dll函数接口: ////******** 初始化默认参数 ********// //extern "C" int __stdcall ZSY3DViewerInit(); //******** 读取历史数据到cloud ********// extern "C" int __stdcall ZSY3DReadHistoryData(char *file_dir); //******** 读取txt数据到cloud ********// extern "C" int __stdcall ZSY3DReadTxtData(char *file_dir); //******** 读取单个点数据到cloud ********// extern "C" int __stdcall ZSY3DReadSingleData(float x, float y, float z); //******** 读取所有点数据到cloud ********// extern "C" int __stdcall ZSY3DReadNowData(float *x, float *y, float *z, int count); //******** vtk读取txt文件并显示 ********// extern "C" int __stdcall ZSY3DReadFile_TXT(char *file_dir); //******** vtk读取obj文件并显示 ********// extern "C" int __stdcall ZSY3DReadFile_OBJ(char *file_dir); //******** vtk读取vtk文件并显示 ********// extern "C" int __stdcall ZSY3DReadFile_VTK(char *file_dir); //******** vtk读取ply文件并显示 ********// extern "C" int __stdcall ZSY3DReadFile_PLY(char *file_dir); //******** cloud下采样处理 ********// extern "C" int __stdcall ZSY3DDownSampling(float leaf_size); //******** cloud均匀采样处理 ********// extern "C" int __stdcall ZSY3DBalanceSampling(float radiusSearch = 0.01f); //******** cloud增采样处理 ********// extern "C" int __stdcall ZSY3DIncreaseSampling(float radius = 0.03f, float StepSize = 0.02f); //******** cloud直通滤波采样处理 ********// extern "C" int __stdcall ZSY3DStraightSampling(char *fieldName = "z", float limits_min = 0.0f, float limits_max = 0.1f, bool limitsNegative = true); //******** cloud统计滤波采样处理 ********// extern "C" int __stdcall ZSY3DStatisticsSampling(float meanK = 50.0f,float stddevMulThresh = 1.0f); //******** cloud半径滤波采样处理 ********// extern "C" int __stdcall ZSY3DRadiusSampling(float radiusSearch = 0.8f, float minNeighborsInRadius = 2.0f); //******** cloud数据进行渲染,并显示 ********// extern "C" int __stdcall ZSY3DShowPointCloud(); //******** cloud数据进行VTK三维重建(三角面绘制),并显示 ********// extern "C" int __stdcall ZSY3DDelaunayBuild(bool depth_color); //******** cloud数据进行VTK三维重建(曲面体绘制),并显示 ********// extern "C" int __stdcall ZSY3DSurfaceBu
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值