【PCL】PCL保存及加载不同格式点云对比

PCL保存及加载不同格式点云对比


前言

PCL中的IO库提供了点云文件输入输出相关的操作类,IO模块利用50多个类与30多个函数来实现点云的获取、读入、存储等。本文以PCL中常见的数据格式PLY和PCD为例,比较不同格式文件的保存以及读取差异。(加载PCD格式点云时,文件名中有中文会报错)测试文件


一、PCL保存为PLY和PCD大小比较

#include <iostream>     
#include <opencv2/opencv.hpp>
#include <pcl/io/pcd_io.h>  
#include <pcl/point_types.h> 
#include <pcl/io/ply_io.h>  
#include <chrono>
using namespace std;
int main()
{
	cv::TickMeter tm;
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	pcl::io::loadPCDFile("lucy.pcd", *cloud);
	//PCD
	tm.start();
	pcl::io::savePCDFileBinary("lucy_binary.pcd", *cloud);
	tm.stop();
	std::cout << "save pcd binary cost time: " << tm.getTimeMilli()<<" ms" << endl;
	tm.start();
	pcl::io::savePCDFileASCII("lucy_ascii.pcd", *cloud);
	tm.stop();
	std::cout << "save pcd ascii cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();
	pcl::io::savePCDFileBinaryCompressed("lucy_binaryCompressed.pcd", *cloud);
	tm.stop();
	std::cout << "save pcd binary_compressed cost time: " << tm.getTimeMilli() << " ms" << endl;

	//PLY
	tm.start();
	pcl::io::savePLYFileBinary("lucy_binary.ply", *cloud);
	tm.stop();
	std::cout << "save ply binary cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();
	pcl::io::savePLYFileASCII("lucy_ascii.ply", *cloud);
	tm.stop();
	std::cout << "save ply ascii cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();
	

	system("pause");
	return 0;
}

耗时:
在这里插入图片描述
保存文件大小:
在这里插入图片描述

二、加载不同格式点云时间对比

#include <iostream>     
#include <opencv2/opencv.hpp>
#include <pcl/io/pcd_io.h>  
#include <pcl/point_types.h> 
#include <pcl/io/ply_io.h>  
#include <chrono>
using namespace std;
int main()
{
	cv::TickMeter tm;
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	
	
	//PCD
	tm.start();
	pcl::io::loadPCDFile("lucy_binary.pcd", *cloud);
	tm.stop();
	std::cout << "load pcd binary cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();
	pcl::io::loadPCDFile("lucy_ascii.pcd", *cloud);
	tm.stop();
	std::cout << "load pcd ascii cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();
	pcl::io::loadPCDFile("lucy_binaryCompressed.pcd", *cloud);
	tm.stop();
	std::cout << "load pcd binary_compressed cost time: " << tm.getTimeMilli() << " ms" << endl;

	//PLY
	tm.start();
	pcl::io::loadPLYFile("lucy_binary.ply", *cloud);
	tm.stop();
	std::cout << "load ply binary cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();
	pcl::io::loadPLYFile("lucy_ascii.ply", *cloud);
	tm.stop();
	std::cout << "load ply ascii cost time: " << tm.getTimeMilli() << " ms" << endl;
	tm.start();

	system("pause");
	return 0;
}

耗时:
在这里插入图片描述

总结

通过上述测试可知,保存文件未binary格式,所占体积最小,加载时,读取binary格式的点云速度最快。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

shanhedian2013

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

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

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

打赏作者

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

抵扣说明:

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

余额充值