Skip to content
Snippets Groups Projects
Verified Commit 7bf29d5a authored by Thibault Payet's avatar Thibault Payet
Browse files

add txt2pcd code

parent d3b29b89
No related branches found
No related tags found
No related merge requests found
int main(int argc, char **argv)
#include <filesystem>
#include <fstream>
#include <iostream>
#include <pcl/io/pcd_io.h>
void txt2pcd( std::filesystem::path input, std::filesystem::path output )
{
std::ifstream inputFile{input.c_str()};
if ( inputFile )
{
pcl::PointCloud<pcl::PointXYZRGB> cloud;
while ( !inputFile.eof() )
{
pcl::PointXYZRGB point;
inputFile >> point.x;
inputFile >> point.y;
inputFile >> point.z;
inputFile >> point.r;
inputFile >> point.g;
inputFile >> point.b;
cloud.push_back( point );
}
pcl::PCDWriter pcdWriter{};
pcdWriter.writeBinaryCompressed( output.string(), cloud );
}
}
void printHelp()
{
std::cout << "Usage: txt2pcd inputCloud.txt outputCloud.pcd\n";
}
int main( int argc, char** argv )
{
if ( argc == 3 )
{
try
{
txt2pcd( argv[ 1 ], argv[ 2 ] );
}
catch ( std::exception const& e )
{
std::cerr << e.what() << "\n";
}
}
else
{
printHelp();
}
return 0;
}
......@@ -5,6 +5,8 @@ pcl_version = get_option('pcl_version')
pcl_io_dep = dependency('pcl_io-@0@'.format(pcl_version),
required: true)
boost_dep = dependency('boost')
executable('txt2pcd', sources: files(['main.cpp']),
dependencies: [pcl_io_dep])
dependencies: [pcl_io_dep, boost_dep])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment