介绍:MC
代码如下:

#include <pcl/PCLPointCloud2.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/vtk_io.h>
#include <pcl/surface/marching_cubes_hoppe.h>
#include <pcl/surface/marching_cubes_rbf.h>
#include<pcl\features\normal_3d.h>
#include <pcl/console/print.h>
#include <pcl/console/parse.h>
#include <pcl/console/time.h>using namespace pcl;
using namespace pcl::io;
using namespace pcl::console;float default_iso_level = 0.0f;
int default_hoppe_or_rbf = 0;
float default_extend_percentage = 0.0f;
int default_grid_res = 50;
float default_off_surface_displacement = 0.01f;void
printHelp (int, char **argv)
{print_error ("Syntax is: %s input.pcd output.vtk <options>\n", argv[0]);print_info ("  where options are:\n");print_info ("                     -grid_res X     = the resolution of the grid (cubic grid) (default: ");print_value ("%d", default_grid_res); print_info (")\n");print_info ("                     -iso_level X    = the iso level of the surface to be extracted (default: ");print_value ("%f", default_iso_level); print_info (")\n");print_info ("                     -hoppe X        = use the Hoppe signed distance function (MarchingCubesHoppe\n");print_info ("                     -rbf X          = use the RBF signed distance function (MarchingCubesRBF\n");print_info ("                     -extend X       = the percentage of the bounding box to extend the grid by (default: ");print_value ("%f", default_extend_percentage); print_info (")\n");print_info ("                     -displacement X = the displacement value for the off-surface points (only for RBF) (default: ");print_value ("%f", default_off_surface_displacement); print_info (")\n");
}bool
loadCloud (const std::string &filename, pcl::PCLPointCloud2 &cloud)
{TicToc tt;print_highlight ("Loading "); print_value ("%s ", filename.c_str ());tt.tic ();if (loadPCDFile (filename, cloud) < 0)return (false);print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%d", cloud.width * cloud.height); print_info (" points]\n");print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (cloud).c_str ());return (true);
}void
compute (const pcl::PCLPointCloud2::ConstPtr &input, PolygonMesh &output,int hoppe_or_rbf, float iso_level, int grid_res, float extend_percentage, float off_surface_displacement)
{PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());fromPCLPointCloud2 (*input, *cloud);pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);tree->setInputCloud(cloud);ne.setInputCloud(cloud);ne.setRadiusSearch(0.02);ne.setSearchMethod(tree);pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);ne.compute(*normals);pcl::PointCloud<pcl::PointNormal>::Ptr xyz_cloud(new pcl::PointCloud<pcl::PointNormal>);pcl::concatenateFields(*cloud, *normals, *xyz_cloud);MarchingCubes<PointNormal> *mc;if (hoppe_or_rbf == 0)mc = new MarchingCubesHoppe<PointNormal> ();else{mc = new MarchingCubesRBF<PointNormal> ();(reinterpret_cast<MarchingCubesRBF<PointNormal>*> (mc))->setOffSurfaceDisplacement (off_surface_displacement);}mc->setIsoLevel (iso_level);mc->setGridResolution (grid_res, grid_res, grid_res);mc->setPercentageExtendGrid (extend_percentage);mc->setInputCloud (xyz_cloud);TicToc tt;tt.tic ();print_highlight ("Computing ");mc->reconstruct (output);delete mc;print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms]\n");
}void
saveCloud (const std::string &filename, const PolygonMesh &output)
{TicToc tt;tt.tic ();print_highlight ("Saving "); print_value ("%s ", filename.c_str ());saveVTKFile (filename, output);print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms]\n");
}/* ---[ */
int
main (int argc, char** argv)
{print_info ("Compute the surface reconstruction of a point cloud using the marching cubes algorithm (pcl::surface::MarchingCubesHoppe or pcl::surface::MarchingCubesRBF. For more information, use: %s -h\n", argv[0]);if (argc < 3){printHelp (argc, argv);return (-1);}// Parse the command line arguments for .pcd filesstd::vector<int> pcd_file_indices;pcd_file_indices = parse_file_extension_argument (argc, argv, ".pcd");if (pcd_file_indices.size () != 1){print_error ("Need one input PCD file and one output VTK file to continue.\n");return (-1);}std::vector<int> vtk_file_indices = parse_file_extension_argument (argc, argv, ".vtk");if (vtk_file_indices.size () != 1){print_error ("Need one output VTK file to continue.\n");return (-1);}// Command line parsingint hoppe_or_rbf = default_hoppe_or_rbf;bool ok = false;parse_argument (argc, argv, "-hoppe", ok);if (ok){hoppe_or_rbf = 0;print_info ("Selected algorithm: MarchingCubesHoppe\n");}ok = false;parse_argument (argc, argv, "-rbf", ok);if (ok){hoppe_or_rbf = 1;print_info ("Selected algorithm: MarchingCubesRBF\n");}float iso_level = default_iso_level;parse_argument (argc, argv, "-iso_level", iso_level);print_info ("Setting an iso level of: "); print_value ("%f\n", iso_level);int grid_res = default_grid_res;parse_argument (argc, argv, "-grid_res", grid_res);print_info ("Setting a cubic grid resolution of: "); print_value ("%d\n", grid_res);float extend_percentage = default_extend_percentage;parse_argument (argc, argv, "-extend", extend_percentage);print_info ("Setting an extend percentage of: "); print_value ("%f\n", extend_percentage);float off_surface_displacement = default_off_surface_displacement;parse_argument (argc, argv, "-displacement", off_surface_displacement);print_info ("Setting an off-surface displacement of: "); print_value ("%f\n", off_surface_displacement);// Load the first filepcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2);if (!loadCloud (argv[pcd_file_indices[0]], *cloud))return (-1);// Apply the marching cubes algorithmPolygonMesh output;compute (cloud, output, hoppe_or_rbf, iso_level, grid_res, extend_percentage, off_surface_displacement);// Save into the second filesaveCloud (argv[vtk_file_indices[0]], output);
}

来源:PCL官方示例

PCL移动立方体MarchingCubes相关推荐

  1. PCL点云处理算法目录

    一.点云配准 PCL中的点云配准方法:https://www.sohu.com/a/321034987_715754 点云配准资源汇总:https://mp.weixin.qq.com/s/rj090 ...

  2. PCL库中Marching Cubes(移动立方体)算法的解析

    PCL库中Marching Cubes(移动立方体)算法解析 1. Marching Cubes算法的原理这里不再赘述,不懂的话,提供一下文献资源: 链接:MARCHING CUBES A HIGH ...

  3. PCL源码剖析之MarchingCubes算法

    MarchingCubes算法简介 MarchingCubes(移动立方体)算法是目前三围数据场等值面生成中最常用的方法.它实际上是一个分而治之的方法,把等值面的抽取分布于每个体素中进行.对于每个被处 ...

  4. PCL体素化降采样 实现立方体体素可视化

    PCL体素化降采样 实现立方体体素可视化 PCL库函数自带的VoxelGrid类能够实现对点云进行降采样.基本原理是对点云进行网格划分,落在每个小立方块区域中的点的重心就代表网格中的所有点.因此通过控 ...

  5. [pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would ov

    1. 报错日志: Python-pcl 点云下采样时报错如下: [pcl::VoxelGrid::applyFilter] Leaf size is too small for the input d ...

  6. PCL:点云中的超体素数据

    -----------------------体素数据---------------------体素化网格 体素(Voxel)是体积元素(Volume pixel)的简称,是数据位于三维空间内规则网格 ...

  7. PCL从0到1|点云滤波之直通滤波与体素法滤波

    3D视觉工坊的第51篇文章 今天呢,想和大家聊一聊点云滤波处理的相关模块. 我对点云模块了解得也不算深入,此处单纯地想和大家分享一下这几天我所学习到的点云滤波知识,如有不到之处,还请后台留言多多指正. ...

  8. PCL谢谢笔记 体素栅格滤波(下采样)

    1.体素滤波 PCL实现的VoxelGrid类通过输入的点云数据创建一个三维体素栅格(可把体素栅格想象为微小的空间三维立方体的集合),然后在每个体素(即,三维立方体)内,用体素中所有点的重心来近似显示 ...

  9. PCL点云库学习笔记 点云的欧式聚类

    欧式聚类详解(点云数据处理) 欧式聚类是一种基于欧氏距离度量的聚类算法.基于KD-Tree的近邻查询算法是加速欧式聚类算法的重要预处理方法. KD-Tree最近邻搜索 Kd-树是K-dimension ...

最新文章

  1. 浅析电商、社区、游戏常用的 MySQL 架构
  2. 通过尾递归避免栈溢出
  3. [图示]做人36字诀:二)形象塑造 ——教你品格高雅
  4. Android——用Activity和Service实现简单的音乐播放器
  5. 如意报表插件如何安装_Google Chrome浏览器如何安装插件应用
  6. 深入分析Java中的关键字static
  7. cleanmymac3.9.6_Android Studio 3.6 特征大揭秘
  8. C#代码执行中等待10秒
  9. jmeter录制脚本(Mac)
  10. 一套完整仿拉勾网HTML静态网页模板(含38个独立HTML)
  11. 尝试docker1.12内置swarm
  12. win10相机计算机无法使用,Win10相机打不开 报错“0xa00f4244”要怎么解决?
  13. 全球股市币市同迎黑色一天 熊市持现金或是王道 | 链塔快评
  14. Linux系统屏幕出现错位重影,win10屏幕出现错位重影怎么办
  15. Golang Fyne项目实战(含源码)
  16. dwm.exe(桌面窗口管理器)占用内存过大解决办法
  17. 在家如何用手机赚钱,小编来为你一一解答!
  18. python gui是什么_python的gui是什么
  19. 【智能制造】同济大学张曙教授:未来工厂;三论智能制造(经典长篇解读)
  20. 215页10万字基于大数据的智慧城市解决方案

热门文章

  1. Android连接SQLServer详细教程(数据库+服务器+客户端)
  2. 简历中如何写上我们接口测试的技能?(附接口开源项目推荐)
  3. bond网卡模式设置
  4. 泰坦综合音源-Best Service Titan Engine | 35GB
  5. [项目设计]高并发内存池
  6. dw连接服务器文件夹,dw远程服务器根文件夹
  7. Mysql报错:Cannot allocate memory for the buffer pool
  8. 自我发展:个体时代如何释放自我价值
  9. 三星i9100通话质量不好声音很小怎么办?
  10. 刽子手游戏(Hangman Judeg,Uva 489)