poisson曲面重建算法

pcl-1.8测试通过

#include <iostream>
#include <pcl/common/common.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/point_types.h>
#include <pcl/surface/mls.h>
#include <pcl/surface/poisson.h>
#include <pcl/filters/passthrough.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp> using namespace pcl;
using namespace std; int
main (int argc, char** argv)
{ /*点云读入阶段*/
if(argc <= 2) {
cout << "请输入点云数据文件名称,并指定输出数据文件名称" << endl;
return 1; }
PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>);
if(io::loadPCDFile<PointXYZ> (argv[1], *cloud) == -1){
cout << "数据读入失败!!" << endl; return 1;
}
cout << "数据读入   完成" << endl; /*滤波阶段*/
PointCloud<PointXYZ>::Ptr filtered(new PointCloud<PointXYZ>());
PassThrough<PointXYZ> filter;
filter.setInputCloud(cloud);
filter.filter(*filtered);
cout << "低通滤波   完成" << endl; // MovingLeastSquares<PointXYZ, PointXYZ> mls;
// mls.setInputCloud(filtered);
// mls.setSearchRadius(0.01);
// mls.setPolynomialFit(true);
// mls.setPolynomialOrder(2);
// mls.setUpsamplingMethod(MovingLeastSquares<PointXYZ, PointXYZ>::SAMPLE_LOCAL_PLANE);
// mls.setUpsamplingRadius(0.005);
// mls.setUpsamplingStepSize(0.003); // PointCloud<PointXYZ>::Ptr cloud_smoothed (new PointCloud<PointXYZ>());
// mls.process(*cloud_smoothed);
// cout << "移动最小二乘平面滤波完成" << endl; /*法向计算阶段*/
NormalEstimationOMP<PointXYZ, Normal> ne;
ne.setNumberOfThreads(8);
ne.setInputCloud(filtered);
ne.setRadiusSearch(5);
Eigen::Vector4f centroid;
compute3DCentroid(*filtered, centroid);
ne.setViewPoint(centroid[0], centroid[1], centroid[2]); PointCloud<Normal>::Ptr cloud_normals (new PointCloud<Normal>());
ne.compute(*cloud_normals); for(size_t i = 0; i < cloud_normals->size(); ++i){
cloud_normals->points[i].normal_x *= -1;
cloud_normals->points[i].normal_y *= -1;
cloud_normals->points[i].normal_z *= -1;
} PointCloud<PointNormal>::Ptr cloud_smoothed_normals(new PointCloud<PointNormal>());
//将点云数据的坐标和法向信息拼接
concatenateFields(*filtered, *cloud_normals, *cloud_smoothed_normals); cout << "法向计算   完成" << endl; /*poission 重建阶段*/
//创建poisson重建对象
Poisson<PointNormal> poisson;
// poisson.setDepth(9);
//输入poisson重建点云数据
poisson.setInputCloud(cloud_smoothed_normals);
//创建网格对象指针,用于存储重建结果
PolygonMesh mesh;
//poisson重建开始
poisson.reconstruct(mesh); //将重建结果存储到硬盘,并保存为PLY格式
io::savePLYFile(argv[2], mesh);
cout << "曲面重建   完成" << endl; /*图形显示阶段*/
cout << "开始图形显示......" << endl;
boost::shared_ptr<pcl::visualization::PCLVisualizer>viewer(new pcl::visualization::PCLVisualizer("my viewer")); viewer->setBackgroundColor(0,0,7);
viewer->addPolygonMesh(mesh, "my");
viewer->addCoordinateSystem(50.0);
viewer->initCameraParameters(); while(!viewer->wasStopped()){ viewer->spinOnce(100);
boost::this_thread::sleep(boost::posix_time::microseconds(100000));
} return (0);
}

pcl曲面重建模块-poisson重建算法示例的更多相关文章

  1. pcl曲面重建模块-贪婪三角形投影算法实例

    贪婪三角形投影算法 在pcl-1.8测试 #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include &l ...

  2. 3D重建算法原理

    3D重建算法原理 三维重建(3D Reconstruction)技术一直是计算机图形学和计算机视觉领域的一个热点课题.早期的三维重建技术通常以二维图像作为输入,重建出场景中的三维模型.但是,受限于输入 ...

  3. backpropagation算法示例

    backpropagation算法示例 下面举个例子,假设在某个mini-batch的有样本X和标签Y,其中\(X\in R^{m\times 2}, Y\in R^{m\times 1}\),现在有 ...

  4. JPEG压缩图像超分辨率重建算法

    压缩图像超分辨率重建算法学习 超分辨率重建是由一幅或多幅的低分辨率图像重构高分辨率图像,如由4幅1m分辨率的遥感图像重构分辨率0.25m分辨率图像.在军用/民用上都有非常大应用. 眼下的超分辨率重建方 ...

  5. Python实现的计算马氏距离算法示例

    Python实现的计算马氏距离算法示例 本文实例讲述了Python实现的计算马氏距离算法.分享给大家供大家参考,具体如下: 我给写成函数调用了 python实现马氏距离源代码:     # encod ...

  6. Python实现的寻找前5个默尼森数算法示例

    Python实现的寻找前5个默尼森数算法示例 本文实例讲述了Python实现的寻找前5个默尼森数算法.分享给大家供大家参考,具体如下: 找前5个默尼森数. 若P是素数且M也是素数,并且满足等式M=2* ...

  7. js 简易模块加载器 示例分析

    前端模块化 关注前端技术发展的各位亲们,肯定对模块化开发这个名词不陌生.随着前端工程越来越复杂,代码越来越多,模块化成了必不可免的趋势. 各种标准 由于javascript本身并没有制定相关标准(当然 ...

  8. 从点云到网格(三)Poisson重建

    Possion重建是Kazhdan等2006年提出的网格重建方法[1].Possion重建的输入是点云及其法向量,输出是三维网格.Poisson有公开的源代码[2].PCL中也有Poisson的实现. ...

  9. PCL贪婪投影三角化算法

    贪婪投影三角化算法是一种对原始点云进行快速三角化的算法,该算法假设曲面光滑,点云密度变化均匀,不能在三角化的同时对曲面进行平滑和孔洞修复. 方法: (1)将三维点通过法线投影到某一平面 (2)对投影得 ...

随机推荐

  1. # ios开发 @property 和 Ivar 的区别

    ios开发 @property 和 Ivar 的区别 @property 属性其实是对成员变量的一种封装.我们先大概这样理解: @property = Ivar + setter + getter I ...

  2. 使用java传参调用exe并且获取程序进度和返回结果的一种方法

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 在某个项目中需要考虑使用java后台调用由C#编写的切图程序( ...

  3. wordpress插件bug排查后记(记一次由于开启memecached引起的插件bug)

    这篇文章是写给自己的. 周三的时候我在维护公司的一个wordpress项目页面时发现了一个非常奇怪的情况:当我尝试更新网站上的一个页面后,在wordpress后台的编辑器中发现其内容并没有按我预期的将 ...

  4. Python基础(二)

    本章内容: Python 运算符(算术运算.比较运算.赋值运算.逻辑运算.成员运算) 基本数据类型(数字.布尔值.字符串.列表.元组.字典.set集合) for 循环 enumrate range和x ...

  5. [JSP]自定义标签库taglib

    自定义标签的步骤 自定义标签的步骤大概有三步: 1.继承javax.servlet.jsp.tagext.*下提供的几个标签类,如Tag.TagSupport.BodyTagSupport.Simpl ...

  6. 在mongoose中使用$match对id失效的解决方法

    Topic.aggregate( //{$match:{_id:"5576b59e192868d01f75486c"}}, //not work //{$match:{title: ...

  7. Python 正则表达式入门(初级篇)

    Python 正则表达式入门(初级篇) 本文主要为没有使用正则表达式经验的新手入门所写. 转载请写明出处 引子 首先说 正则表达式是什么? 正则表达式,又称正规表示式.正规表示法.正规表达式.规则表达 ...

  8. 自己封装的一个原生JS拖动方法。

    代码: function drag(t,p){ var point = p || null, target = t || null, resultX = 0, resultY = 0; (!point ...

  9. Netty简介

    Netty简介 Netty是由JBOSS提供的一个Java开源框架.Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速开发高性能.高可靠性的网络服务器和客户端程序.和传统BIO不同,NI ...

  10. 【WCF】基于WCF的在线升级

    一.前言       前不久因公司产品需要完成了在线升级功能,因为编程技术不精,不敢冒然采用Socket方法实现在线升级,所以使用比较方便稳妥的WCF方式 如果考虑并发能力的话还是Socket> ...