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
21
22//----------------------------------------------------------------------------------
26//----------------------------------------------------------------------------------
28{
29public:
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
50protected:
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);
67 double intPart=0;
68 for (int c=0; c < 4; ++c){
69 for (int 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.
74 retMatrix[static_cast<size_t>(c)][static_cast<size_t>(r)] = intPart/floatDigitsMultiplier;
75 }
76 }
77 return retMatrix;
78 }
79
81 template <typename PCL_FILTER>
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>
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
100private:
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
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:58
Field to encapsulate a double value.
Definition mlFields.h:538
Base class for all fields used in the ML.
Definition mlField.h:73
Field to encapsulate an integer value.
Definition mlFields.h:126
Field to encapsulate a 4x4 matrix.
Definition mlFields.h:1682
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...
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.
void handleNotification(Field *field) override
Handles field changes of the field field.
BoolField & getHasConvergedFld() const
DoubleField & getTransformationEpsilonFld() const
void activateAttachments() override
Updates internal state after changes of fields without field notifications.
DoubleField & getEuclideanFitnessEpsilonFld() const
void _setFilterParameters(PCL_FILTER &regObject) const
Sets the filter parameters known from this class.
Matrix4Field & getLastIncrementalTransformationFld() const
void _retrieveFilterResultParameters(PCL_FILTER &regObject)
Retrieves output parameters from filter known in this class.
IntField & getMaximumIterationsFld() const
Input fields: For documentation see corresponding field documentation.
DoubleField & getFitnessScoreFld() const
Matrix4Field & getFinalTransformationFld() const
Output fields: For documentation see corresponding field documentation.
DoubleField & getMaxCorrespondenceDistanceFld() 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).
Target mlrange_cast(Source arg)
Generic version of checked ML casts.