Outliers.cpp
Go to the documentation of this file.
1 #include "../utest.h"
3 
4 using namespace std;
5 using namespace PointMatcherSupport;
6 
7 //---------------------------
8 // Outlier modules
9 //---------------------------
10 
11 // Utility classes
13 {
14 public:
15  std::shared_ptr<PM::OutlierFilter> testedOutlierFilter;
16 
17  // Will be called for every tests
18  virtual void SetUp()
19  {
20  icp.setDefault();
21  // Uncomment for console outputs
22  //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
23 
24  icp.outlierFilters.clear();
25  }
26 
27  // Will be called for every tests
28  virtual void TearDown(){}
29 
30  void addFilter(string name, PM::Parameters params)
31  {
32  testedOutlierFilter =
33  PM::get().OutlierFilterRegistrar.create(name, params);
34  icp.outlierFilters.push_back(testedOutlierFilter);
35  }
36 
37 };
38 
39 //No commun parameters were found for 2D and 3D, tests are spliced
40 TEST_F(OutlierFilterTest, MaxDistOutlierFilter2D)
41 {
42  addFilter("MaxDistOutlierFilter", {
43  {"maxDist", toParam(0.10)}
44  }
45  );
46  validate2dTransformation();
47 }
48 
49 TEST_F(OutlierFilterTest, MaxDistOutlierFilter3D)
50 {
51  addFilter("MaxDistOutlierFilter", {
52  {"maxDist", toParam(1.0)}
53  }
54  );
55  validate3dTransformation();
56 }
57 
58 //No commun parameters were found for 2D and 3D, tests are spliced
59 TEST_F(OutlierFilterTest, MinDistOutlierFilter2D)
60 {
61  // Since not sure how useful is that filter, we keep the
62  // MaxDistOutlierFilter with it
63  std::shared_ptr<PM::OutlierFilter> extraOutlierFilter;
64 
65  extraOutlierFilter =
66  PM::get().OutlierFilterRegistrar.create(
67  "MaxDistOutlierFilter", {
68  {"maxDist", toParam(0.10)}
69  }
70  );
71  icp.outlierFilters.push_back(extraOutlierFilter);
72 
73  addFilter("MinDistOutlierFilter", {{"minDist", toParam(0.0002)}});
74 
75  validate2dTransformation();
76 }
77 
78 TEST_F(OutlierFilterTest, MinDistOutlierFilter3D)
79 {
80  // Since not sure how useful is that filter, we keep the
81  // MaxDistOutlierFilter with it
82  std::shared_ptr<PM::OutlierFilter> extraOutlierFilter;
83 
84  extraOutlierFilter =
85  PM::get().OutlierFilterRegistrar.create(
86  "MaxDistOutlierFilter", {
87  {"maxDist", toParam(1.0)}
88  }
89  )
90  ;
91  icp.outlierFilters.push_back(extraOutlierFilter);
92 
93  addFilter("MinDistOutlierFilter", {{"minDist", toParam(0.0002)}});
94 
95  validate3dTransformation();
96 }
97 
98 TEST_F(OutlierFilterTest, MedianDistOutlierFilter)
99 {
100  addFilter("MedianDistOutlierFilter", {{"factor", toParam(3.5)}});
101  validate2dTransformation();
102  validate3dTransformation();
103 }
104 
105 
106 TEST_F(OutlierFilterTest, TrimmedDistOutlierFilter)
107 {
108  addFilter("TrimmedDistOutlierFilter", {{"ratio", toParam(0.85)}});
109  validate2dTransformation();
110  validate3dTransformation();
111 }
112 
113 
114 TEST_F(OutlierFilterTest, VarTrimmedDistOutlierFilter)
115 {
116  addFilter("VarTrimmedDistOutlierFilter", {
117  {"minRatio", toParam(0.60)},
118  {"maxRatio", toParam(0.80)},
119  {"lambda", toParam(0.9)}
120  }
121  );
122  validate2dTransformation();
123  validate3dTransformation();
124 }
125 
127  OutlierFiltersImpl<float>::VarTrimmedDistOutlierFilter filter({{"minRatio", toParam(0.0000001)},
128  {"maxRatio", toParam(1.0)},
129  {"lambda", toParam(lambda)}});
130  PointMatcher<float>::DataPoints filteredReading;
131  PointMatcher<float>::DataPoints filteredReference;
132 
133  // Create a vector a distance
135  dists << 4, 5, 5, 5, 5;
137  PointMatcher<float>::Matches input(dists, ids);
138  return filter.compute(filteredReading, filteredReference, input);
139 }
140 
141 TEST_F(OutlierFilterTest, VarTrimmedDistOutlierFilterParameters)
142 {
143  // A lambda parameter of zero, all matches will be reject except for the minimum
145  // The minimum is the first value
146  ASSERT_EQ(1.0f, weights(0, 0));
147  ASSERT_EQ(0.0f, weights(0, 1));
148 
149  weights = VarTrimLambdaTest(1.0);
150  ASSERT_EQ(1.0f, weights(0, 0));
151  ASSERT_EQ(1.0f, weights(0, 1));
152 }
PointMatcher< float >::Parameters
Parametrizable::Parameters Parameters
alias
Definition: PointMatcher.h:186
PointMatcherSupport::toParam
std::string toParam(const S &value)
Return the a string value using lexical_cast.
Definition: Parametrizable.h:92
kitti-run-seq.f
string f
Definition: kitti-run-seq.py:12
OutlierFiltersImpl.h
OutlierFiltersImpl::OutlierWeights
PointMatcher< T >::OutlierWeights OutlierWeights
Definition: OutlierFiltersImpl.h:54
OutlierFilterTest::SetUp
virtual void SetUp()
Definition: Outliers.cpp:18
OutlierFilterTest::testedOutlierFilter
std::shared_ptr< PM::OutlierFilter > testedOutlierFilter
Definition: Outliers.cpp:15
PointMatcher
Functions and classes that are dependant on scalar type are defined in this templatized class.
Definition: PointMatcher.h:130
ASSERT_EQ
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:19781
IcpHelper
Definition: utest.h:31
OutlierFilterTest::TearDown
virtual void TearDown()
Definition: Outliers.cpp:28
OutlierFilterTest
Definition: Outliers.cpp:12
TEST_F
TEST_F(OutlierFilterTest, MaxDistOutlierFilter2D)
Definition: Outliers.cpp:40
OutlierFilterTest::addFilter
void addFilter(string name, PM::Parameters params)
Definition: Outliers.cpp:30
std
OutlierFiltersImpl::VarTrimmedDistOutlierFilter
Definition: OutlierFiltersImpl.h:147
VarTrimLambdaTest
OutlierFiltersImpl< float >::OutlierWeights VarTrimLambdaTest(const float lambda)
Definition: Outliers.cpp:126
PointMatcher< float >::get
static const PointMatcher & get()
Return instances.
Definition: Registry.cpp:141
PointMatcherSupport
Functions and classes that are not dependant on scalar type are defined in this namespace.
Definition: Bibliography.cpp:45


mp2p_icp
Author(s):
autogenerated on Thu Dec 26 2024 03:48:12