reduce_fpfh_training_data.cpp
Go to the documentation of this file.
00001 
00064 #include "cob_3d_features/most_discriminating_data_points.h"
00065 #include <boost/program_options.hpp>
00066 
00067 #include <pcl/point_types.h>
00068 #include <pcl/io/pcd_io.h>
00069 
00070 using namespace std;
00071 using namespace pcl;
00072 
00073 string in_, out_;
00074 int k_;
00075 
00076 void readOptions(int argc, char* argv[])
00077 {
00078   using namespace boost::program_options;
00079   options_description options("Options");
00080   options.add_options()
00081     ("help", "produce help message")
00082     ("in", value<string>(&in_), "input fpfh pcd")
00083     ("out", value<string>(&out_), "output fpfh pcd")
00084     ("intervals,k", value<int>(&k_)->default_value(100), "k means value")
00085     ;
00086 
00087   positional_options_description p_opt;
00088   p_opt.add("in",1).add("out", 1);
00089   variables_map vm;
00090   store(command_line_parser(argc, argv).options(options).positional(p_opt).run(), vm);
00091   notify(vm);
00092 
00093   if (vm.count("help"))
00094   {
00095     cout << options << endl;
00096     exit(0);
00097   }
00098 }
00099 
00100 int main(int argc, char** argv)
00101 {
00102   readOptions(argc, argv);
00103   PointCloud<FPFHSignature33>::Ptr f_in (new PointCloud<FPFHSignature33>);
00104   PointCloud<FPFHSignature33>::Ptr f_out (new PointCloud<FPFHSignature33>);
00105 
00106   io::loadPCDFile<FPFHSignature33>(in_, *f_in);
00107   cout << "loaded fpfh" << endl;
00108   vector<vector<float> > d_in;
00109   vector<vector<float> > d_out;
00110 
00111   d_in.resize(f_in->size());
00112   for (size_t n=0;n<f_in->size();n++)
00113   {
00114     d_in.at(n) = vector<float>(f_in->points[n].histogram,
00115                                f_in->points[n].histogram +
00116                                sizeof(f_in->points[n].histogram) / sizeof(float));
00117   }
00118   cout << "copied fpfh" << endl;
00119   cob_3d_features::MostDiscriminatingDataPoints md;
00120   md.setInputData(&d_in);
00121   md.setK(k_);
00122   md.computeDataPoints(&d_out);
00123   cout << "computed kmeans" << endl;
00124 
00125   f_out->points.resize(k_);
00126 
00127   for (size_t k=0; k<k_; k++)
00128   {
00129     for (size_t m=0;m<33;m++) f_out->points[k].histogram[m] = d_out.at(k).at(m);
00130   }
00131   cout << "saved fpfh" << endl;
00132   io::savePCDFileASCII<FPFHSignature33>(out_, *f_out);
00133   return (0);
00134 }


cob_3d_evaluation_features
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:38