PCL小工具一:pcd格式的点云转成ply格式的点云

环境:ubuntu18.04 + pcl1.8
主要还是使用了pcl库中的一些简单的函数实现

src/pcd2ply.cpp:

//用于把点云由pcd文件转为ply文件
#include <iostream>
#include <pcl/io/pcd_io.h>  
#include <pcl/io/ply_io.h>

#include <pcl/point_types.h>  

using namespace std;
using namespace pcl;

string pcd_path = "/home/jy/Desktop/2011_09_30/2011_09_30_drive_0027_sync/velodyne_points/out_fliter_010.pcd";
string ply_path = "/home/jy/Desktop/2011_09_30/2011_09_30_drive_0027_sync/velodyne_points/out_fliter_010.ply";

int PCDtoPLYconvertor(string & input_filename ,string& output_filename)
{
    //此处的PointXYZI可以换成PointXYZ等其他格式的,看自己点云的格式来,只要整个程序统一即可
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);
    if (pcl::io::loadPCDFile<pcl::PointXYZI>(input_filename, *cloud) == -1)
    {
        PCL_ERROR("Couldn't read pcd file \n");
        return (-1);
    }
    pcl::PLYWriter writer;
    writer.write<pcl::PointXYZI> (output_filename, *cloud, false);
    // writer.write(ply_path, cloud, Eigen::Vector4f::Zero(), Eigen::Quaternionf::Identity(),true,true);

    return 0;

}


int main(int argc, char **argv){
    PCDtoPLYconvertor(pcd_path,ply_path);
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

set(CMAKE_BUILD_TYPE "Release")
# 添加c++ 11标准支持
set(CMAKE_CXX_FLAGS "-std=c++11 -O2")

find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})

add_executable (pcd2ply src/pcd2ply.cpp) 
target_link_libraries(pcd2ply ${PCL_LIBRARIES})

如果遇到编译问题可能是pcl库的版本不同。如果还是无法解决可在评论区留言~

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山楂没我渣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值