Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00046 #include <iostream>
00047 #include <pcl/common/io.h>
00048 #include <pcl/io/pcd_io.h>
00049
00050 using namespace std;
00051
00052
00053 int
00054 main (int argc, char** argv)
00055 {
00056 if (argc < 4)
00057 {
00058 std::cerr << "Syntax is: " << argv[0] << " <file_in.pcd> <file_out.pcd> 0/1/2 (ascii/binary/binary_compressed) [precision (ASCII)]" << std::endl;
00059 return (-1);
00060 }
00061
00062 sensor_msgs::PointCloud2 cloud;
00063 Eigen::Vector4f origin; Eigen::Quaternionf orientation;
00064
00065 if (pcl::io::loadPCDFile (string (argv[1]), cloud, origin, orientation) < 0)
00066 {
00067 std::cerr << "Unable to load " << argv[1] << std::endl;
00068 return (-1);
00069 }
00070
00071 int type = atoi (argv[3]);
00072
00073 std::cerr << "Loaded a point cloud with " << cloud.width * cloud.height <<
00074 " points (total size is " << cloud.data.size () <<
00075 ") and the following channels: " << pcl::getFieldsList (cloud) << std::endl;
00076
00077 pcl::PCDWriter w;
00078 if (type == 0)
00079 {
00080 std::cerr << "Saving file " << argv[2] << " as ASCII." << std::endl;
00081 w.writeASCII (string (argv[2]), cloud, origin, orientation, (argc == 5) ? atoi (argv[4]) : 7);
00082 }
00083 else if (type == 1)
00084 {
00085 std::cerr << "Saving file " << argv[2] << " as binary." << std::endl;
00086 w.writeBinary (string (argv[2]), cloud, origin, orientation);
00087 }
00088 else if (type == 2)
00089 {
00090 std::cerr << "Saving file " << argv[2] << " as binary_compressed." << std::endl;
00091 w.writeBinaryCompressed (string (argv[2]), cloud, origin, orientation);
00092 }
00093 }
00094