Go to the documentation of this file.00001
00002
00003
00004
00005
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> <summarizationMethod (optional) 2 or 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
00045
00046 DP in(DP::load(argv[1]));
00047
00048 std::shared_ptr<PM::DataPointsFilter> randomSample =
00049 PM::get().DataPointsFilterRegistrar.create(
00050 "RandomSamplingDataPointsFilter",
00051 {{"prob", toParam(0.5)}}
00052 );
00053
00054 cout << "starting random sample filter" << endl;
00055 clock_t time_a = clock();
00056 randomSample->inPlaceFilter(in);
00057 clock_t time_b = clock();
00058
00059 if (time_a == ((clock_t)-1) || time_b == ((clock_t)-1))
00060 {
00061 perror("Unable to calculate elapsed time");
00062 return -1;
00063 }
00064 else
00065 {
00066 cout << "Performed random sampling in " << (float)(time_b - time_a)/CLOCKS_PER_SEC << " seconds" << endl;
00067 }
00068
00069 std::shared_ptr<PM::DataPointsFilter> voxelf =
00070 PM::get().DataPointsFilterRegistrar.create(
00071 "VoxelGridDataPointsFilter",
00072 {
00073 {"vSizeX", "0.2"},
00074 {"vSizeY", "0.2"},
00075 {"vSizeZ", "0.2"},
00076 {"useCentroid",useCentroid},
00077 {"averageExistingDescriptors","0"}
00078 }
00079 );
00080
00081 cout << "starting voxel grid sample filter, useCentroid: " << useCentroid << endl;
00082 time_a = clock();
00083 voxelf->inPlaceFilter(in);
00084 time_b = clock();
00085
00086 if (time_a == ((clock_t)-1) || time_b == ((clock_t)-1))
00087 {
00088 perror("Unable to calculate elapsed time");
00089 return -1;
00090 }
00091 else
00092 {
00093 cout << "Performed voxel grid sampling in " << (float)(time_b - time_a)/CLOCKS_PER_SEC << " seconds" << endl;
00094 }
00095
00096 return 0;
00097 }
00098
00099