rgb_to_rgba.cpp
Go to the documentation of this file.
00001 
00063 #include <boost/program_options.hpp>
00064 
00065 #include <pcl/io/pcd_io.h>
00066 #include <pcl/point_types.h>
00067 
00068 using namespace pcl;
00069 using namespace std;
00070 
00071 string in_, out_;
00072 
00073 void readOptions(int argc, char* argv[])
00074 {
00075   using namespace boost::program_options;
00076   options_description options("Options");
00077   options.add_options()
00078     ("help", "produce help message")
00079     ("in", value<string>(&in_), "input file rgb")
00080     ("out",value<string>(&out_),"output file rgba")
00081     ;
00082 
00083   positional_options_description p_opt;
00084   p_opt.add("in", 1).add("out",1);
00085   variables_map vm;
00086   store(command_line_parser(argc, argv).options(options).positional(p_opt).run(), vm);
00087   notify(vm);
00088 
00089   if (vm.count("help") || !vm.count("in") || !vm.count("in"))
00090   {
00091     cout << options << endl;
00092     exit(0);
00093   }
00094 }
00095 
00096 int main (int argc, char** argv)
00097 {
00098   readOptions(argc, argv);
00099   PointCloud<PointXYZRGB>::Ptr p(new PointCloud<PointXYZRGB>);
00100   PointCloud<PointXYZRGBA>::Ptr p2(new PointCloud<PointXYZRGBA>);
00101 
00102   io::loadPCDFile<PointXYZRGB>(in_, *p);
00103   p2->width = p->width;
00104   p2->height = p->height;
00105   p2->points.resize(p2->width * p2->height);
00106   for (size_t i = 0; i < p->points.size(); i++)
00107   {
00108     p2->points[i].x = p->points[i].x;
00109     p2->points[i].y = p->points[i].y;
00110     p2->points[i].z = p->points[i].z;
00111     p2->points[i].rgba = *reinterpret_cast<int*>(&p->points[i].rgb);
00112   }
00113   io::savePCDFileASCII<PointXYZRGBA>(out_, *p2);
00114 
00115   return 0;
00116 }


cob_3d_mapping_tools
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:27