Ubuntu16.04将点云bin文件转成pcd文件

0. 前言

笔者最近做在Ubuntu16.04下将点云bin文件转成pcd文件,借鉴的学习资料为小邋遢-lxh博主的两篇博客文章:

1. 遇到的问题

在做第一步没有遇到任何问题,最终也成功的测试了pcl安装是否成功!提示一下,刚开始大家可能看到的效果如下:
在这里插入图片描述
很多人误以为自己是不是做的不合适还是咋了,怎么和该博客主的最终效果不一致,其实大家做到这一步,pcl就已经安装正确并成功了,要显示和该博客主的一样效果,大家可以通过滑动鼠标滚轮,慢慢就会发现显示出原来博客主类似的运行效果了。
在这里插入图片描述

但是在做到第二篇文章的时候,按照博主的操作新建完所有文件夹的时候,在cmake编译完之后,执行make命令时给我报了一个错误,错误截图如下:
在这里插入图片描述

2. 错误分析以及解决办法

根据系统的提示,显示的是没有pcl/common/point_operators.h这个头文件,我一直以为是自己PCL安装是不是不合适,没有安装好哪个包或者依赖啥的,又重新安装配置了一遍PCL,但是最终效果还是和之前一样。
后面我又开始查了一些其他关于PCL的程序,发现和其他博主并没有引这个头文件,于是将这个头文件删了,然后分别进行cmake ..make操作,最终make成功了,make成功截图如下:
在这里插入图片描述
具体修改如下:
将该博主的bin2pcd.cpp替换为下面的程序:

#include <boost/program_options.hpp>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/common/io.h>
#include <pcl/search/organized.h>
#include <pcl/search/octree.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/segmentation/extract_clusters.h>
#include <pcl/surface/gp3.h>
#include <pcl/io/vtk_io.h>
#include <pcl/filters/voxel_grid.h>
 
#include <iostream>
#include <fstream>
 
using namespace pcl;
using namespace std;
 
namespace po = boost::program_options;
 
int main(int argc, char **argv){
	///The file to read from.
	string infile;
 
	///The file to output to.
	string outfile;
 
	// Declare the supported options.
	po::options_description desc("Program options");
	desc.add_options()
		//Options
		("infile", po::value<string>(&infile)->required(), "the file to read a point cloud from")
		("outfile", po::value<string>(&outfile)->required(), "the file to write the DoN point cloud & normals to")
		;
	// Parse the command line
	po::variables_map vm;
	po::store(po::parse_command_line(argc, argv, desc), vm);
 
	// Print help
	if (vm.count("help"))
	{
		cout << desc << "\n";
		return false;
	}
 
	// Process options.
	po::notify(vm);
 
	// load point cloud
	fstream input(infile.c_str(), ios::in | ios::binary);
	if(!input.good()){
		cerr << "Could not read file: " << infile << endl;
		exit(EXIT_FAILURE);
	}
	input.seekg(0, ios::beg);
 
	pcl::PointCloud<PointXYZI>::Ptr points (new pcl::PointCloud<PointXYZI>);
 
	int i;
	for (i=0; input.good() && !input.eof(); i++) {
		PointXYZI point;
		input.read((char *) &point.x, 3*sizeof(float));
		input.read((char *) &point.intensity, sizeof(float));
		points->push_back(point);
	}
	input.close();
 
	cout << "Read KTTI point cloud with " << i << " points, writing to " << outfile << endl;
 
    pcl::PCDWriter writer;
 
    // Save DoN features
    writer.write<PointXYZI> (outfile, *points, false);
}

其他操作继续按照该博主的操作进行即可!

3. 备注

最终我们成功把.bin文件转成了.pcd格式,
在这里插入图片描述
我的研究方向不是图像处理这一块,因为这是帮我研二的一个师兄做的一个小工作,但是我很好奇pcd格式文件到底是啥,我怎么看到这个效果,网上查了一些资料,发现利用命令pcl_viewer工具可以查看实际图像:
命令如下:

pcl_viewer XXX.pcd 
//如果没有安装pcl_viewer,请实验 sudo apt-get install pcl_viewer安装此插件

最终显示效果如下:
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值