Outliers.cpp
Go to the documentation of this file.
00001 #include "../utest.h"
00002 #include "pointmatcher/OutlierFiltersImpl.h"
00003 
00004 using namespace std;
00005 using namespace PointMatcherSupport;
00006 
00007 //---------------------------
00008 // Outlier modules
00009 //---------------------------
00010 
00011 // Utility classes
00012 class OutlierFilterTest: public IcpHelper
00013 {
00014 public:
00015         std::shared_ptr<PM::OutlierFilter> testedOutlierFilter;
00016 
00017         // Will be called for every tests
00018         virtual void SetUp()
00019         {
00020                 icp.setDefault();
00021                 // Uncomment for console outputs
00022                 //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
00023                 
00024                 icp.outlierFilters.clear();
00025         }
00026 
00027         // Will be called for every tests
00028         virtual void TearDown(){}
00029 
00030         void addFilter(string name, PM::Parameters params)
00031         {
00032                 testedOutlierFilter = 
00033                         PM::get().OutlierFilterRegistrar.create(name, params);
00034                 icp.outlierFilters.push_back(testedOutlierFilter);
00035         }
00036 
00037 };
00038 
00039 //No commun parameters were found for 2D and 3D, tests are spliced
00040 TEST_F(OutlierFilterTest, MaxDistOutlierFilter2D)
00041 {
00042         addFilter("MaxDistOutlierFilter", {
00043                         {"maxDist", toParam(0.10)}
00044                 }
00045         );
00046         validate2dTransformation();
00047 }
00048 
00049 TEST_F(OutlierFilterTest, MaxDistOutlierFilter3D)
00050 {
00051         addFilter("MaxDistOutlierFilter", {
00052                         {"maxDist", toParam(1.0)}
00053                 }
00054         );
00055         validate3dTransformation();
00056 }
00057 
00058 //No commun parameters were found for 2D and 3D, tests are spliced
00059 TEST_F(OutlierFilterTest, MinDistOutlierFilter2D)
00060 {
00061         // Since not sure how useful is that filter, we keep the 
00062         // MaxDistOutlierFilter with it
00063         std::shared_ptr<PM::OutlierFilter> extraOutlierFilter;
00064         
00065         extraOutlierFilter = 
00066                 PM::get().OutlierFilterRegistrar.create(
00067                         "MaxDistOutlierFilter", {
00068                                 {"maxDist", toParam(0.10)}
00069                         }
00070                 );
00071         icp.outlierFilters.push_back(extraOutlierFilter);
00072         
00073         addFilter("MinDistOutlierFilter", {{"minDist", toParam(0.0002)}});
00074         
00075         validate2dTransformation();
00076 }
00077 
00078 TEST_F(OutlierFilterTest, MinDistOutlierFilter3D)
00079 {
00080         // Since not sure how useful is that filter, we keep the 
00081         // MaxDistOutlierFilter with it
00082         std::shared_ptr<PM::OutlierFilter> extraOutlierFilter;
00083         
00084         extraOutlierFilter = 
00085                 PM::get().OutlierFilterRegistrar.create(
00086                         "MaxDistOutlierFilter", {
00087                                 {"maxDist", toParam(1.0)}
00088                         }
00089                 )
00090         ;
00091         icp.outlierFilters.push_back(extraOutlierFilter);
00092         
00093         addFilter("MinDistOutlierFilter", {{"minDist", toParam(0.0002)}});
00094         
00095         validate3dTransformation();
00096 }
00097 
00098 TEST_F(OutlierFilterTest, MedianDistOutlierFilter)
00099 {
00100         addFilter("MedianDistOutlierFilter", {{"factor", toParam(3.5)}});
00101         validate2dTransformation();
00102         validate3dTransformation();
00103 }
00104 
00105 
00106 TEST_F(OutlierFilterTest, TrimmedDistOutlierFilter)
00107 {
00108         addFilter("TrimmedDistOutlierFilter", {{"ratio", toParam(0.85)}});
00109         validate2dTransformation();
00110         validate3dTransformation();
00111 }
00112 
00113 
00114 TEST_F(OutlierFilterTest, VarTrimmedDistOutlierFilter)
00115 {
00116         addFilter("VarTrimmedDistOutlierFilter", {
00117                         {"minRatio", toParam(0.60)},
00118                         {"maxRatio", toParam(0.80)},
00119                         {"lambda", toParam(0.9)}
00120                 }
00121         );
00122         validate2dTransformation();
00123         validate3dTransformation();
00124 }
00125 
00126 OutlierFiltersImpl<float>::OutlierWeights VarTrimLambdaTest(const float lambda) {
00127         OutlierFiltersImpl<float>::VarTrimmedDistOutlierFilter filter({{"minRatio", toParam(0.0000001)},
00128                                                                                                                                    {"maxRatio", toParam(1.0)},
00129                                                                                                                                    {"lambda", toParam(lambda)}});
00130         PointMatcher<float>::DataPoints filteredReading;
00131         PointMatcher<float>::DataPoints filteredReference;
00132 
00133         // Create a vector a distance
00134         PointMatcher<float>::Matches::Dists dists(1, 5);
00135         dists << 4, 5, 5, 5, 5;
00136         PointMatcher<float>::Matches::Ids ids(1, 5);
00137         PointMatcher<float>::Matches input(dists, ids);
00138         return filter.compute(filteredReading, filteredReference, input);
00139 }
00140 
00141 TEST_F(OutlierFilterTest, VarTrimmedDistOutlierFilterParameters)
00142 {
00143         // A lambda parameter of zero, all matches will be reject except for the minimum
00144         OutlierFiltersImpl<float>::OutlierWeights weights = VarTrimLambdaTest(0.0);
00145         // The minimum is the first value
00146         ASSERT_EQ(1.0f, weights(0, 0));
00147         ASSERT_EQ(0.0f, weights(0, 1));
00148 
00149         weights = VarTrimLambdaTest(1.0);
00150         ASSERT_EQ(1.0f, weights(0, 0));
00151         ASSERT_EQ(1.0f, weights(0, 1));
00152 }


libpointmatcher
Author(s):
autogenerated on Thu Jun 20 2019 19:51:32