filterProfiler.cpp
Go to the documentation of this file.
00001 /*
00002  * filterProfiler.cpp
00003  *
00004  *  Created on: Feb 27, 2014
00005  *      Author: sam
00006  */
00007 
00008 #include <iostream>
00009 #include <pointmatcher/PointMatcher.h>
00010 #include <boost/assign.hpp>
00011 #include <ctime>
00012 #include <time.h>
00013 
00014 using namespace PointMatcherSupport;
00015 using namespace std;
00016 using namespace boost;
00017 
00018 typedef PointMatcher<float> PM;
00019 typedef PM::DataPoints DP;
00020 typedef PM::Parameters Parameters;
00021 
00022 int main(int argc, char *argv[])
00023 {
00024 
00025         if (argc < 2 || argc > 3)
00026                 {
00027                 std::cerr << "USAGE: filterProfiler <path_to_input_cloud> <useCentroids (optional) 1 or 0>" << std::endl;
00028                 return -1;
00029                 }
00030 
00031         char* useCentroid;
00032         if (argc == 3) {
00033                 if (strcmp(argv[2],"1") != 0 && strcmp(argv[2],"0")) {
00034                         cerr << "param useCentroid must be 1 or 0" << endl;
00035                         return -1;
00036                 } else
00037                 {
00038                         useCentroid = argv[2];
00039                 }
00040         } else {
00041                 useCentroid = "1";
00042         }
00043 
00044                 //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
00045 
00046                 DP in(DP::load(argv[1]));
00047 
00048                 PM::DataPointsFilter* randomSample(
00049                                 PM::get().DataPointsFilterRegistrar.create(
00050                                                 "RandomSamplingDataPointsFilter",
00051                                                 map_list_of
00052                                                 ("prob", toParam(0.5))
00053                                 )
00054                 );
00055 
00056                 cout << "starting random sample filter" << endl;
00057                 clock_t time_a = clock();
00058                 randomSample->inPlaceFilter(in);
00059                 clock_t time_b = clock();
00060 
00061                 if (time_a == ((clock_t)-1) || time_b == ((clock_t)-1))
00062                 {
00063                     perror("Unable to calculate elapsed time");
00064                     return -1;
00065                 }
00066                 else
00067                 {
00068                     cout << "Performed random sampling in " << (float)(time_b - time_a)/CLOCKS_PER_SEC << " seconds" << endl;
00069                 }
00070 
00071                 PM::DataPointsFilter* voxelf(
00072                                 PM::get().DataPointsFilterRegistrar.create(
00073                                                 "VoxelGridDataPointsFilter",
00074                                                 map_list_of
00075                                                 ("vSizeX", "0.2")
00076                                                 ("vSizeY", "0.2")
00077                                                 ("vSizeZ", "0.2")
00078                                                 ("useCentroid",useCentroid)
00079                                                 ("averageExistingDescriptors","0")
00080                                 )
00081                 );
00082 
00083                 cout << "starting voxel grid sample filter, useCentroid: " << useCentroid << endl;
00084                 time_a = clock();
00085                 voxelf->inPlaceFilter(in);
00086                 time_b = clock();
00087 
00088                 if (time_a == ((clock_t)-1) || time_b == ((clock_t)-1))
00089                 {
00090                         perror("Unable to calculate elapsed time");
00091                         return -1;
00092                 }
00093                 else
00094                 {
00095                         cout << "Performed voxel grid sampling in " << (float)(time_b - time_a)/CLOCKS_PER_SEC << " seconds" << endl;
00096                 }
00097 
00098                 return 0;
00099 }
00100 
00101 


upstream_src
Author(s):
autogenerated on Mon Oct 6 2014 10:27:39