Convert PLY to VTK Using PCL 1.6.0 使用PCL库将PLY格式转为VTK格式
PLY格式是比较流行的保存点云Point Cloud的格式,可以用MeshLab等软件打开,而VTK是医学图像处理中比较常用的格式,可以使用VTK库和ITK库进行更加复杂的运算处理。我们可以使用ParaView软件对VTK格式文件进行预览和简单处理,ParaView也可以打开PLY格式,但是就没有texture了,而且我们如果直接用ParaView导出VTK格式也没有texture的,这不是我们想要的结果。MeshLab虽然可以打开有texture的PLY文件,但是却不支持导出VTK格式,那么我们如何将PLY转为VTK格式并且保留texture呢?我们可以用PCL库来转换,PCL全称是Point Cloud Library,是专门处理点云的库,功能十分强大,提供saveVTKFile函数可以保存vtk,就是要注意参数的类型,做一些类型转换即可。
Using PCL 1.6.0:
// PCL 1.6.0
#include <iostream>
#include <string> #include <pcl/io/vtk_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/ros/conversions.h>
#include <sensor_msgs/PointCloud2.h> typedef pcl::PointXYZRGB PointT;
typedef pcl::PointCloud<PointT> PointCloudT; int main() { std::string filename = "in.ply";
PointCloudT::Ptr pc(new PointCloudT);
if (pcl::io::loadPLYFile (filename, *pc) == -) {
PCL_ERROR("Error reading point cloud %s\n", filename.c_str());
return ;
} sensor_msgs::PointCloud2 cloud2;
pcl::toROSMsg(*pc, cloud2)
pcl::io::saveVTKFile("out.vtk", cloud2); return ;
}
Using PCL 1.8.0:
// PCL 1.8.0
#include <iostream>
#include <string> #include <pcl/io/vtk_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/conversions.h> typedef pcl::PointXYZRGB PointT;
typedef pcl::PointCloud<PointT> PointCloudT; int main() { std::string filename = "in.ply";
PointCloudT::Ptr pc(new PointCloudT);
if (pcl::io::loadPLYFile (filename, *pc) == -) {
PCL_ERROR("Error reading point cloud %s\n", filename.c_str());
return ;
} pcl::PCLPointCloud2 cloud2;
pcl::toPCLPointCloud2(*pc, cloud2);
pcl::io::saveVTKFile("out.vtk", cloud2); return ;
}
VTK格式的点云关于texture的存储方式有两种,第一种是需要有texture的图片,然后每个点存储上该点在图片中的x,y坐标,一般会normalize到[0,1]之间。第二种方法是直接存每个点的rgb值,上面的方法用的是第二种,因为导入的PLY格式就直接存储的texture的rgb值,并没有额外提供texture图片,这种方法导出的vtk格式,在VTK库的viewer中显示是有texture的,大功告成!
Convert PLY to VTK Using PCL 1.6.0 使用PCL库将PLY格式转为VTK格式的更多相关文章
- Convert PLY to VTK Using PCL 1.6.0 or PCL 1.8.0 使用PCL库将PLY格式转为VTK格式
PLY格式是比较流行的保存点云Point Cloud的格式,可以用MeshLab等软件打开,而VTK是医学图像处理中比较常用的格式,可以使用VTK库和ITK库进行更加复杂的运算处理.我们可以使用Par ...
- PCL 1.6.0 VS2010 Configuration
Open VS2010, create a new project, then open Property Manager, double-click Microsoft.Cpp.win32.user ...
- PCL 1.4.0 VS 2010 Configuration
Open VS2010, create a new project, then open Property Manager, double-click Microsoft.Cpp.win32.user ...
- macOS 安装 pcl 1.8.0
Mac 上的 pcl 一直有问题. 找不到 pcl_viewer 查看 pcd 文件.写个程序用 pcl::visualization::CloudViewer 查看点云,遇到 Runtime Exc ...
- ros pcl sensor::pointcloud2 转换成pcl::pointcloud
#include <pcl_conversions/pcl_conversions.h> #include <pcl/point_types.h> #include <p ...
- PCL(Point Cloud Library)的第三方库简单介绍(boost,eigen,flann,vtk,qhull)
PCL由于融合了大量的第三方开源库,导致学习成本升高~在学习之前我们最好还是了解一下这些库都是干嘛的,以便有的放矢.在之后更好的使用 boost: C++的标准库的备用版,擅长从数学库到智能指针,从模 ...
- Ubuntu 16.04 上安装 PCL 1.8.0
Ubuntu16.04之后安装pcl可以直接apt-get sudo apt-get install libpcl-dev pcl-tools 安装之前,准备一些依赖库 sudo apt-get up ...
- Qt 4.8.6 PCL 1.8.0 VS 2010 联合编译常见错误
在Qt和PCL联合编译的过程中,会出现各种各样的错误,解决这些错误的过程真是痛苦万分,所以总结一些常见错误方便自己也方便他人.比如我们要编译PCL1.8.0中的apps中的point_cloud_ed ...
- linux下关于PCL(point cloud library)库的安装,三行命令错误的问题
最近想再看看PCL,所以进行了安装,在之前的接触的过程中,由于之前的网络存在问题,导致以下三个命令: sudo add-apt-repository ppa:v-launchpad-jochen-sp ...
随机推荐
- Xcode工作区间xxxx.xcworkspace不包含xxxx.xcodeproj
一.问题描述 项目用到cocoapods管理第三方框架,所以需要打开xxxx.xcworkspace,Pods正常显示,但xxxx.xcodeproj显示红色,不包含xxxx.xcodeproj并且无 ...
- myeclipse2015卸载、安装、破解全过程-----myeclipse2015
myeclipse2015安装以及破解步骤: 下载地址:myeclipse2015-->https://pan.baidu.com/s/1i4RFCBb 密码:qxsu 破解文件地址--&g ...
- 使用JHChart勾勒你想要的图表
前言 从2016年4月14日开始,本人着手开发了JHChart图表工具库.经过断断续续的开发,截止到现在,已经实现了折线图.柱状图.饼状图.环形图和表格样式的图表功能.为了方便使用,我已经将一个简单的 ...
- CentOS7 cacti 安装
首先centos7 web环境的安装这里就不说了.安装cacti,首先得web环境配置好 其次添加两个用户,一个是cacti用于操作mysql的 cactimysql 一个是cacti操作Linux ...
- Shell 脚本实现随机抽取班级学生
#/bin/bash function rand(){ min=$ max=$(($-$min+)) num=$(date +%s%N) echo $(($num%$max+$min)) } rnd= ...
- Visual Studio将std::cout输出到Output窗口
在debug的时候,输出到Output需要使用OutputDebugString函数,但部分库的log是采用std::cout输出的,需要用控制台(黑窗)程序来查看输出.有没有一种使用GUI和Outp ...
- MYSQL数据库相关知识合集
1 MYSQL取得某一范围随机数: 关键词:RAND() [产生0~1之间的随机数] mysql> SELECT RAND( ), RAND( ), RAND( ); +----------- ...
- [Java 8] (10) 使用Lambda完成函数组合,Map-Reduce以及并行化
好文推荐!!!!! 原文见:http://blog.csdn.net/dm_vincent/article/details/40856569 Java 8中同时存在面向对象编程(OOP)和函数式编程( ...
- JsonHelper developed by using Newtonsoft.Json.NET, Deserialize to <T> object , XmlToJson/JsonToXml, QuoteName by using JToken Path.
namespace TestConsoleApplication { using System; using System.Diagnostics; using System.Threading; u ...
- Server.MapPath()
./当前目录/网站主目录../上层目录~/网站虚拟目录 如果当前的网站目录为E:\wwwroot 应用程序虚拟目录为E:\wwwroot\company 浏览的页面路径为E:\wwwroot\co ...