Ubuntu16.04 converts point cloud bin files to pcd files

0. Preface

The author recently did the conversion of point cloud bin files into pcd files under Ubuntu 16.04. The learning materials used for reference are two blog posts by the little sloppy-lxh blogger:

1. Problems encountered

I did not encounter any problems in the first step, and finally successfully tested whether the pcl installation was successful! As a reminder, the effect that you may see at the beginning is as follows:
Insert picture description here
Many people mistakenly think that they are doing something inappropriate or something wrong, and why they are inconsistent with the final effect of the blogger. In fact, if you do this step, the pcl has been installed correctly. And it was successful. To display the same effect as the blog owner, you can slide the mouse wheel, and slowly you will find that the original blog owner has a similar operating effect.
Insert picture description here

But when I did the second article, when all the folders were created according to the blogger's operation, after cmake was compiled, I reported an error when I executed the make command. The screenshot of the error is as follows:
Insert picture description here

2. Error analysis and solutions

According to the system's prompt, it shows that there is no pcl/common/point_operators.hsuch header file. I always thought that my PCL installation is not appropriate, I did not install which package or depended on, and reinstalled and configured PCL again, but the final effect was still the same as before. .
Later I began to check some other program on PCL, discoveries and other bloggers did not lead this header file, so this header file deleted, and then separately cmake ..and makeoperations, and ultimately make a success, make successful shots are as follows:
Insert picture description here
Specific Amend as follows:
replace the blogger's bin2pcd.cpp with the following program:

#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);
}

Other operations can continue to follow the blogger's operations!

3. Remarks

In the end, we successfully converted the .bin file to the .pcd format.
Insert picture description here
My research direction is not image processing, because this is a small job done by a brother who helped me in the second study, but I am very curious about what the pcd format file is. How do I see this effect? ​​I checked some information on the Internet and found that the actual image can be viewed using the command pcl_viewer tool: The
command is as follows:

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

The final display effect is as follows:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_37955704/article/details/110548313