Go to the documentation of this file.00001
00063
00064 #include <boost/program_options.hpp>
00065
00066 #include <pcl/point_types.h>
00067 #include <pcl/io/pcd_io.h>
00068
00069 #include "cob_3d_mapping_common/io.h"
00070
00071 using namespace std;
00072 using namespace pcl;
00073
00074 vector<string> file_o(2, "");
00075 string file_i = "";
00076
00077 float min_z, max_z;
00078
00079 void readOptions(int argc, char* argv[])
00080 {
00081 using namespace boost::program_options;
00082 options_description options("Options");
00083 options.add_options()
00084 ("help", "produce help message")
00085 ("in", value<string>(&file_i), "input pcd file")
00086 ("out", value< vector<string> >(&file_o), "output files, first rgb, [second depth]")
00087 ("min,m", value<float>(&min_z)->default_value(FLT_MAX), "min value of depth range")
00088 ("max,M", value<float>(&max_z)->default_value(FLT_MIN), "max value of depth range")
00089 ;
00090
00091 positional_options_description p_opt;
00092 p_opt.add("in", 1).add("out", 2);
00093 variables_map vm;
00094 store(command_line_parser(argc, argv).options(options).positional(p_opt).run(), vm);
00095 notify(vm);
00096
00097 if (vm.count("help"))
00098 {
00099 cout << "Reads a point cloud and extracts color and depth values as .ppm image" << endl;
00100 cout << options << endl;
00101 exit(0);
00102 }
00103 if (file_i == "")
00104 {
00105 cout << "no input and output file defined " << endl << options << endl;
00106 exit(0);
00107 }
00108 if (file_o[0] == "")
00109 {
00110 cout << "no output file defined " << endl << options << endl;
00111 exit(0);
00112 }
00113 }
00114
00118 int main(int argc, char** argv)
00119 {
00120 readOptions(argc, argv);
00121 PointCloud<PointXYZRGB>::Ptr p(new PointCloud<PointXYZRGB>());
00122
00123 PCDReader r;
00124 if (r.read(file_i, *p) == -1) return(0);
00125
00126 cout << "Loaded pointcloud with " << p->width << " x " << p->height << " points." << endl;
00127
00128 cob_3d_mapping_common::PPMWriter w;
00129 if (w.writeRGB(file_o[0], *p) == -1) return(0);
00130 cout << "Extracted RGB image..." << endl;
00131
00132 if (file_o[1] != "")
00133 {
00134 if (min_z != FLT_MAX)
00135 w.setMinZ(min_z);
00136 if (max_z != FLT_MIN)
00137 w.setMaxZ(max_z);
00138
00139 if (w.writeDepth(file_o[1], *p) == -1) return(0);
00140 if (w.writeDepthLinear(file_o[1] + "_linear", *p) == -1) return(0);
00141 cout << "Extracted depth image..." << endl;
00142 }
00143
00144 cout << "Done!" << endl;
00145
00146 return(0);
00147 }