Go to the documentation of this file.00001
00068 #include <boost/program_options.hpp>
00069 #include <iostream>
00070
00071 #include <pcl/point_types.h>
00072 #include <pcl/io/pcd_io.h>
00073 #include <pcl/common/file_io.h>
00074
00075
00076
00077 using namespace std;
00078 using namespace pcl;
00079
00080 string outfolder_;
00081 vector<string> folder_in_;
00082
00083 void readOptions(int argc, char* argv[])
00084 {
00085 using namespace boost::program_options;
00086
00087 options_description cmd_line("Options");
00088 cmd_line.add_options()
00089 ("help", "produce help messsage")
00090 ("out,o", value<string>(&outfolder_), "output folder")
00091 ("in,i", value<vector<string> >(&folder_in_), "list folders containing input files")
00092 ;
00093
00094 positional_options_description p_opt;
00095 p_opt.add("in", -1);
00096
00097 variables_map vm;
00098 store(command_line_parser(argc, argv)
00099 .options(cmd_line)
00100 .positional(p_opt).run(), vm);
00101 notify(vm);
00102
00103 if (vm.count("help") || !vm.count("in"))
00104 {
00105 cout << "Script to merge fpfh PCD files from multiple objects into a single file for each class."
00106 << endl;
00107 cout << "Searches for files containing the strings:" << endl;
00108 cout << "\t \"plane\"" << endl;
00109 cout << "\t \"edge_convex_\"" << endl;
00110 cout << "\t \"edge_concave_\"" << endl;
00111 cout << "\t \"sphere_convex_\"" << endl;
00112 cout << "\t \"sphere_concave_\"" << endl;
00113 cout << "\t \"cylinder_convex_\"" << endl;
00114 cout << "\t \"cylinder_concave_\"" << endl;
00115 cout << cmd_line << endl;
00116 exit(0);
00117 }
00118 }
00119
00120 int main(int argc, char** argv)
00121 {
00122 readOptions(argc, argv);
00123
00124 PointCloud<FPFHSignature33> plane, e_vex, e_cav, c_vex, c_cav, s_vex, s_cav, tmp;
00125 PCDReader r;
00126 for (size_t j = 0; j < folder_in_.size(); j++)
00127 {
00128 vector<string> files;
00129 getAllPcdFilesInDirectory(folder_in_[j], files);
00130 for (size_t i = 0; i < files.size(); i++)
00131 {
00132 files[i] = folder_in_[j] + files[i];
00133 r.read(files[i], tmp);
00134 if(string::npos != files[i].rfind("plane"))
00135 plane += tmp;
00136 else if (string::npos != files[i].rfind("edge_convex_"))
00137 e_vex += tmp;
00138 else if (string::npos != files[i].rfind("edge_concave_"))
00139 e_cav += tmp;
00140 else if (string::npos != files[i].rfind("sphere_convex_"))
00141 s_vex += tmp;
00142 else if (string::npos != files[i].rfind("sphere_concave_"))
00143 s_cav += tmp;
00144 else if (string::npos != files[i].rfind("cylinder_convex_"))
00145 c_vex += tmp;
00146 else if (string::npos != files[i].rfind("cylinder_concave_"))
00147 c_cav += tmp;
00148 tmp.clear();
00149 }
00150 }
00151
00152 PCDWriter w;
00153 w.write(outfolder_ + "fpfh_plane_.pcd", plane);
00154 w.write(outfolder_ + "fpfh_edge_convex_.pcd", e_vex);
00155 w.write(outfolder_ + "fpfh_cylinder_convex_.pcd", c_vex);
00156 w.write(outfolder_ + "fpfh_sphere_convex_.pcd", s_vex);
00157 w.write(outfolder_ + "fpfh_edge_concave_.pcd", e_cav);
00158 w.write(outfolder_ + "fpfh_cylinder_concave_.pcd", c_cav);
00159 w.write(outfolder_ + "fpfh_sphere_concave_.pcd", s_cav);
00160
00161 return 1;
00162 }