filterProfiler.cpp
Go to the documentation of this file.
1 /*
2  * filterProfiler.cpp
3  *
4  * Created on: Feb 27, 2014
5  * Author: sam
6  */
7 
8 #include <iostream>
10 #include <boost/assign.hpp>
11 #include <ctime>
12 #include <time.h>
13 
14 using namespace PointMatcherSupport;
15 using namespace std;
16 using namespace boost;
17 
21 
22 int main(int argc, char *argv[])
23 {
24 
25  if (argc < 2 || argc > 3)
26  {
27  std::cerr << "USAGE: filterProfiler <path_to_input_cloud> <summarizationMethod (optional) 2 or 1 or 0>" << std::endl;
28  return -1;
29  }
30 
31  char* useCentroid;
32  if (argc == 3) {
33  if (strcmp(argv[2],"1") != 0 && strcmp(argv[2],"0")) {
34  cerr << "param useCentroid must be 1 or 0" << endl;
35  return -1;
36  } else
37  {
38  useCentroid = argv[2];
39  }
40  } else {
41  useCentroid = "1";
42  }
43 
44  //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
45 
46  DP in(DP::load(argv[1]));
47 
48  std::shared_ptr<PM::DataPointsFilter> randomSample =
49  PM::get().DataPointsFilterRegistrar.create(
50  "RandomSamplingDataPointsFilter",
51  {{"prob", toParam(0.5)}}
52  );
53 
54  cout << "starting random sample filter" << endl;
55  clock_t time_a = clock();
56  randomSample->inPlaceFilter(in);
57  clock_t time_b = clock();
58 
59  if (time_a == ((clock_t)-1) || time_b == ((clock_t)-1))
60  {
61  perror("Unable to calculate elapsed time");
62  return -1;
63  }
64  else
65  {
66  cout << "Performed random sampling in " << (float)(time_b - time_a)/CLOCKS_PER_SEC << " seconds" << endl;
67  }
68 
69  std::shared_ptr<PM::DataPointsFilter> voxelf =
70  PM::get().DataPointsFilterRegistrar.create(
71  "VoxelGridDataPointsFilter",
72  {
73  {"vSizeX", "0.2"},
74  {"vSizeY", "0.2"},
75  {"vSizeZ", "0.2"},
76  {"useCentroid",useCentroid},
77  {"averageExistingDescriptors","0"}
78  }
79  );
80 
81  cout << "starting voxel grid sample filter, useCentroid: " << useCentroid << endl;
82  time_a = clock();
83  voxelf->inPlaceFilter(in);
84  time_b = clock();
85 
86  if (time_a == ((clock_t)-1) || time_b == ((clock_t)-1))
87  {
88  perror("Unable to calculate elapsed time");
89  return -1;
90  }
91  else
92  {
93  cout << "Performed voxel grid sampling in " << (float)(time_b - time_a)/CLOCKS_PER_SEC << " seconds" << endl;
94  }
95 
96  return 0;
97 }
98 
99 
PointMatcher< float >::Parameters
Parametrizable::Parameters Parameters
alias
Definition: PointMatcher.h:186
PointMatcherSupport::toParam
std::string toParam(const S &value)
Return the string value using lexical_cast.
Definition: Parametrizable.h:123
Parameters
PM::Parameters Parameters
Definition: filterProfiler.cpp:20
DataPoints
PM::DataPoints DataPoints
Definition: pypoint_matcher_helper.h:16
main
int main(int argc, char *argv[])
Definition: filterProfiler.cpp:22
PointMatcher< float >
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
PM
PointMatcher< float > PM
Definition: filterProfiler.cpp:18
std
DP
PM::DataPoints DP
Definition: filterProfiler.cpp:19
PointMatcher< float >::get
static const PointMatcher & get()
Return instances.
Definition: Registry.cpp:146
PointMatcherSupport
Functions and classes that are not dependant on scalar type are defined in this namespace.
Definition: Bibliography.cpp:45
PointMatcher::DataPoints::load
static DataPoints load(const std::string &fileName)
Load a point cloud from a file, determine format from extension.
Definition: pointmatcher/IO.cpp:375
PointMatcher.h
public interface


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:08