MeVisLab Toolbox Reference
mlPCLRegistration.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code author="Wolf Spindler"
3 //----------------------------------------------------------------------------------
7 
14 //----------------------------------------------------------------------------------
15 #pragma once
16 
18 #include <mlPCLModule.h>
19 
20 ML_START_NAMESPACE
21 
22 //----------------------------------------------------------------------------------
26 //----------------------------------------------------------------------------------
28 {
29 public:
32  PCLRegistration(int numInputs=2, int numOutputs=1);
33 
36  IntField & getMaximumIterationsFld () const { return *_maximumIterationsFld; }
37  DoubleField & getMaxCorrespondenceDistanceFld () const { return *_maxCorrespondenceDistanceFld; }
38  DoubleField & getTransformationEpsilonFld () const { return *_transformationEpsilonFld; }
39  DoubleField & getEuclideanFitnessEpsilonFld () const { return *_euclideanFitnessEpsilonFld; }
41 
44  Matrix4Field & getFinalTransformationFld () const { return *_finalTransformationFld; }
45  Matrix4Field & getLastIncrementalTransformationFld () const { return *_lastIncrementalTransformationFld; }
46  DoubleField & getFitnessScoreFld () const { return *_fitnessScoreFld; }
47  BoolField & getHasConvergedFld () const { return *_hasConvergedFld; }
49 
50 protected:
52  void activateAttachments() override;
53 
55  void handleNotification (Field* field) override;
56 
59 
63  static inline Matrix4 _pclToMLType(Eigen::Matrix<float, 4, 4> inputType)
64  {
65  const double floatDigitsMultiplier = pow(10., FLT_DIG+1);
66  Matrix4 retMatrix;
67  double intPart=0;
68  for (size_t c=0; c < 4; ++c){
69  for (size_t r=0; r < 4; ++r){
70  // Multiply with 10 ^ available floating point digits,
71  // take integer part and divide it to get original number
72  // without stuff after floating point digits in double values.
73  modf(inputType.col(c)[r]*floatDigitsMultiplier, &intPart);
74  retMatrix[c][r] = intPart/floatDigitsMultiplier;
75  }
76  }
77  return retMatrix;
78  }
79 
81  template <typename PCL_FILTER>
82  inline void _setFilterParameters(PCL_FILTER &regObject) const
83  {
84  regObject.setMaximumIterations (mlrange_cast<int>(getMaximumIterationsFld().getIntValue()));
85  regObject.setMaxCorrespondenceDistance(getMaxCorrespondenceDistanceFld().getDoubleValue());
86  regObject.setTransformationEpsilon (getTransformationEpsilonFld().getDoubleValue());
87  regObject.setEuclideanFitnessEpsilon (getEuclideanFitnessEpsilonFld().getDoubleValue());
88  }
89 
91  template <typename PCL_FILTER>
92  inline void _retrieveFilterResultParameters(PCL_FILTER &regObject)
93  {
94  getFitnessScoreFld().setDoubleValue(regObject.getFitnessScore());
95  getFinalTransformationFld().setMatrixValue(_pclToMLType(regObject.getFinalTransformation()));
96  getLastIncrementalTransformationFld().setMatrixValue(_pclToMLType(regObject.getLastIncrementalTransformation()));
97  getHasConvergedFld().setBoolValue(regObject.hasConverged());
98  }
99 
100 private:
101 
103  void _clampValues();
104 
105  // ---- Input fields:
107  IntField *_maximumIterationsFld;
108 
111  DoubleField *_maxCorrespondenceDistanceFld;
112 
115  DoubleField *_transformationEpsilonFld;
116 
120  DoubleField *_euclideanFitnessEpsilonFld;
121 
122  // ---- Output fields:
124  Matrix4Field *_finalTransformationFld;
125 
127  Matrix4Field *_lastIncrementalTransformationFld;
128 
130  DoubleField *_fitnessScoreFld;
131 
133  BoolField *_hasConvergedFld;
134 
136  virtual void _filter() = 0;
137 
140 };
141 
142 ML_END_NAMESPACE
143 
Project global and OS specific declarations.
#define MLPCL_Registration_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Field to encapsulate a boolean value.
Definition: mlFields.h:62
Field to encapsulate a double value.
Definition: mlFields.h:806
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate an integer value.
Definition: mlFields.h:161
Field to encapsulate a 4x4 matrix.
Definition: mlFields.h:2420
ML Module base class for algorithms from the Point Cloud Library (PCL).
Definition: mlPCLModule.h:26
Abstract ML Module class wrapping the pcl::Registration class from the PCL; PCL registration algorith...
void _addPCLRelatedFields()
Adds fields corresponding to the registration class covered with this class, already called by constr...
DoubleField & getFitnessScoreFld() const
static Matrix4 _pclToMLType(Eigen::Matrix< float, 4, 4 > inputType)
Helper function to converts the input pcl 4x4 matrix to a double matrix and to throw away precision a...
PCLRegistration(int numInputs=2, int numOutputs=1)
Initializes an ML module wrapping a pcl::Registration filter.
IntField & getMaximumIterationsFld() const
Input fields: For documentation see corresponding field documentation.
void handleNotification(Field *field) override
Handles field changes of the field field.
DoubleField & getTransformationEpsilonFld() const
void activateAttachments() override
Updates internal state after changes of fields without field notifications.
Matrix4Field & getFinalTransformationFld() const
Output fields: For documentation see corresponding field documentation.
void _setFilterParameters(PCL_FILTER &regObject) const
Sets the filter parameters known from this class.
DoubleField & getMaxCorrespondenceDistanceFld() const
void _retrieveFilterResultParameters(PCL_FILTER &regObject)
Retrieves output parameters from filter known in this class.
DoubleField & getEuclideanFitnessEpsilonFld() const
BoolField & getHasConvergedFld() const
Matrix4Field & getLastIncrementalTransformationFld() const
#define ML_ABSTRACT_MODULE_CLASS_HEADER(className)
Like ML_ABSTRACT_CLASS_HEADER for the usage of derived classes from Module.
ML Module base class for algorithms from the Point Cloud Library (PCL).