PCL点云曲面重建--重采样
2017-08-26 15:58 Lonya 阅读(6439) 评论(1) 编辑 收藏 举报测量较小的对象时产生一些误差,直接重建会使曲面不光滑或者有漏洞,为了建立完整的模型需要对表面进行平滑处理和漏洞修复.可通过数据重建来解决这一问题,重采样算法通过对周围数据点进行高阶多项式插值来重建表面缺少的部分.
由多个扫描配准后得到的数据直接拿来重建可能产生 "双墙"等重影,即拼接的区域出现重叠的两个曲面,重采样算法可以对此问题进行处理.
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张不同角度的点云拼接而成,左边呈现重影,右图为处理结果图,重影消除.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架