ErrorMinimizers.cpp
Go to the documentation of this file.
00001 #include "../utest.h"
00002 
00003 using namespace std;
00004 using namespace PointMatcherSupport;
00005 
00006 //---------------------------
00007 // Error modules
00008 //---------------------------
00009 
00010 // Utility classes
00011 class ErrorMinimizerTest: public IcpHelper
00012 {
00013 public:
00014         std::shared_ptr<PM::ErrorMinimizer> errorMin;
00015 
00016         // Will be called for every tests
00017         virtual void SetUp()
00018         {
00019                 icp.setDefault();
00020                 // Uncomment for consol outputs
00021                 //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
00022         }
00023 
00024         // Will be called for every tests
00025         virtual void TearDown(){}
00026 
00027         void setError(string name)
00028         {
00029                 errorMin = PM::get().ErrorMinimizerRegistrar.create(name);
00030                 icp.errorMinimizer = errorMin;
00031         }
00032 };
00033 
00034 
00035 TEST_F(ErrorMinimizerTest, PointToPointErrorMinimizer)
00036 {
00037         setError("PointToPointErrorMinimizer");
00038         validate2dTransformation();
00039         validate3dTransformation();
00040 }
00041 
00042 TEST_F(ErrorMinimizerTest, PointToPlaneErrorMinimizer)
00043 {
00044         setError("PointToPlaneErrorMinimizer");
00045         validate2dTransformation();
00046         validate3dTransformation();
00047 }
00048 
00049 TEST_F(ErrorMinimizerTest, ErrorElements)
00050 {
00051         const unsigned int nbPoints = 100;
00052         const unsigned int dimFeatures = 4;
00053         const unsigned int dimDescriptors = 3;
00054         const unsigned int dimTime = 2;
00055 
00056         // Fake DataPoints
00057         PM::Matrix randFeat = PM::Matrix::Random(dimFeatures, nbPoints);
00058         DP::Labels featLabels;
00059         featLabels.push_back(DP::Label("x", 1));
00060         featLabels.push_back(DP::Label("y", 1));
00061         featLabels.push_back(DP::Label("z", 1));
00062         featLabels.push_back(DP::Label("pad", 1));
00063 
00064         PM::Matrix randDesc = PM::Matrix::Random(dimDescriptors, nbPoints);
00065         DP::Labels descLabels;
00066         descLabels.push_back(DP::Label("dummyDesc", 3));
00067 
00068         PM::Int64Matrix randTimes = PM::Int64Matrix::Random(dimTime, nbPoints);
00069         DP::Labels timeLabels;
00070         timeLabels.push_back(DP::Label("dummyTime", 2));
00071 
00072         // Construct the point cloud from the generated matrices
00073         DP request = DP(randFeat, featLabels, randDesc, descLabels, randTimes, timeLabels);
00074         DP source =  DP(randFeat, featLabels, randDesc, descLabels, randTimes, timeLabels);
00075         
00076         // Fake Weights
00077         PM::OutlierWeights weights = PM::OutlierWeights::Ones(1, nbPoints);
00078 
00079         // Fake Matches
00080         PM::Matches::Ids ids(1, nbPoints);
00081         PM::Matches::Dists dists(1, nbPoints);
00082 
00083         for(unsigned int i=0; i<nbPoints; i++)
00084         {
00085                 ids(0,i) = i;
00086                 dists(0,i) = 1.0;
00087         }
00088 
00089         // Construct matches from generated matrices
00090         PM::Matches matches(dists, ids);
00091 
00092         
00093         // Finally, the constructor for ErrorElements
00094         PM::ErrorMinimizer::ErrorElements mPts(request, source, weights, matches);
00095 
00096         // check number of points
00097         EXPECT_EQ(mPts.reference.getNbPoints(), nbPoints);
00098         EXPECT_EQ(mPts.reference.getNbPoints(), mPts.reading.getNbPoints());
00099 
00100         // check descriptor
00101         EXPECT_EQ(mPts.reference.getDescriptorDim(), dimDescriptors);
00102         
00103         // check time
00104         EXPECT_EQ(mPts.reference.getTimeDim(), dimTime);
00105 
00106 }
00107 


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