当前位置: 首页 > news >正文

PCL 无序点云的快速三角剖分

这个程序可以把3D点云里的点组合成很多三角形,然后把这些三角形拼接生成连续表面。

先看看输入的3D点云:

程序运行后会显示生成的连续表面:

输入:bun0.pcd

输出:没有保存输出结果

运行:编译后直接双击即可运行

代码:

#include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include <pcl/search/kdtree.h> // for KdTree #include <pcl/features/normal_3d.h> #include <pcl/surface/gp3.h> int main () { // Load input file into a PointCloud<T> with an appropriate type pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); pcl::PCLPointCloud2 cloud_blob; pcl::io::loadPCDFile ("bun0.pcd", cloud_blob); pcl::fromPCLPointCloud2 (cloud_blob, *cloud); //* the data should be available in cloud // Normal estimation* pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n; pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>); pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>); tree->setInputCloud (cloud); n.setInputCloud (cloud); n.setSearchMethod (tree); n.setKSearch (20); n.compute (*normals); //* normals should not contain the point normals + surface curvatures // Concatenate the XYZ and normal fields* pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::PointNormal>); pcl::concatenateFields (*cloud, *normals, *cloud_with_normals); //* cloud_with_normals = cloud + normals // Create search tree* pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>); tree2->setInputCloud (cloud_with_normals); // Initialize objects pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3; pcl::PolygonMesh triangles; // Set the maximum distance between connected points (maximum edge length) gp3.setSearchRadius (0.025); // Set typical values for the parameters gp3.setMu (2.5); gp3.setMaximumNearestNeighbors (100); gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees gp3.setMinimumAngle(M_PI/18); // 10 degrees gp3.setMaximumAngle(2*M_PI/3); // 120 degrees gp3.setNormalConsistency(false); // Get result gp3.setInputCloud (cloud_with_normals); gp3.setSearchMethod (tree2); gp3.reconstruct (triangles); // Additional vertex information std::vector<int> parts = gp3.getPartIDs(); std::vector<int> states = gp3.getPointStates(); // Finish return (0); }

参考:Fast triangulation of unordered point clouds — Point Cloud Library 0.0 documentation

http://www.jsqmd.com/news/1151310/

相关文章:

  • 【单片机毕业设计】基于 51/STM32 单片机的超声波测距声光报警系统设计,基于 STM32/51 单片机的近距离测距预警装置开发(022901)
  • AI 眼镜不是下一台手机,而是 AI 终于长出了眼睛
  • 理解平衡树数据结构在数据库索引中的核心价值
  • 爱丁堡大学与MIT联手打造的AI科学家
  • 终极Armbian部署指南:将闲置电视盒子变身高性能Linux服务器
  • 倒装芯片封装 3 种凸块工艺对比:金/铜柱/锡凸块选型与 5 项关键参数
  • Scikit-learn 1.5实战:3行代码完成K-Means聚类与逻辑回归分类
  • 暗黑破坏神2存档编辑器完整技术指南:从入门到深度定制
  • HFSS 2024 R2 仿真分析:微带线与带状线在 20GHz 下的辐射与串扰差异
  • 数值计算优化:避免浮点数误差的算法设计
  • HarmonyKit | 鸿蒙新特性实践:UUID v4 生成器的纯 ArkTS 实现
  • 信号完整性设计实战:3种端接方案消除反射,眼图张开度提升40%
  • 如何高效找回加密压缩包的密码:ArchivePasswordTestTool完全指南
  • OpenCV/Python 实现热红外 NUC:3 种校正算法实战与 640x512 图像效果对比
  • 5分钟快速上手:终极免费Chrome视频下载助手完整指南
  • 实时推荐系统架构设计与优化
  • 非技术人想转AI,不一定要转开发,可以先转向AI应用型岗位
  • 【AI专栏】图解Transformer - 第04章:LLM生成
  • BMS AFE芯片开路诊断逻辑深度解析(硬件原理+工程实现+避坑方案)
  • IntelliJ IDEA高效使用指南
  • 提升中标率基础要素
  • 【单片机毕业设计】基于 51 单片机的二路超声波测距报警系统设计与实现,基于 STM32 单片机的双路超声波测距预警装置开发(023001)
  • 6款靠谱降AIGC平台 降痕效果拉满
  • 导师都惊呆了!8个AI写作辅助软件,从选题到润色全包了!
  • BiliDownloader终极指南:5步掌握B站视频下载的完整方案
  • 开发自定义工具(重要)
  • Cas:1260247-50-4,Biotin-PEG3-SS-NH2,生物素-聚乙二醇-双硫键-氨基
  • 数字频率计 PCB 设计 3 要点:Altium Designer 22 布局布线实战避坑指南
  • TPD2015FN与PIC18F46K42构建高性价比负载控制系统
  • ChatGPT生成的代码能直接运行吗?这5项必须人工检查