ply格式以及pcd文件的显示

35 篇文章 1 订阅
20 篇文章 0 订阅

使用PCL读取并显示ply格式的点云文件:

创建main.cpp,代码如下:


#include <iostream>
#include <pcl/point_types.h>
#include <pcl/io/ply_io.h>
#include <pcl/visualization/pcl_visualizer.h>


typedef pcl::PointXYZ PointT;
typedef pcl::PointCloud<PointT> PointCloudT;

int main(int argc,char** argv)
{
        PointCloudT::Ptr cloud(new PointCloudT);
		
		// 读取点云
        std::string filename = argv[1];
        if (pcl::io::loadPLYFile(filename, *cloud)<0)
        {
                std::cout << "error";
        }

		// 点云显示
        pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
        viewer->setBackgroundColor (0, 0, 0);
        viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
        viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud");
        viewer->initCameraParameters ();
        while (!viewer->wasStopped())
        {
                viewer->spinOnce();
        }

        return 0;
}

创建 CMakeLists.txt文件:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(ply_viewer)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable (ply_viewer main.cpp)
target_link_libraries (ply_viewer ${PCL_LIBRARIES})

 对代码进行编译:

mkdir build
cd build 
cmake ..
make

然后在build文件夹下执行指令:其中../Surfels-xyz.ply为ply格式文件所在位置:

./ply_viewer ../Surfels-xyz.ply

最后显示的结果:

利用pcl_viewer工具讀取pcd格式文件:
pcl_viewer my_128.pcd

結果顯示:

 

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

稻壳特筑

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

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

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

打赏作者

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

抵扣说明:

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

余额充值