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
20ML_START_NAMESPACE
21
22//----------------------------------------------------------------------------------
26//----------------------------------------------------------------------------------
28{
29public:
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
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);
66 Matrix4 retMatrix;
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.
73 modf(inputType.col(c)[r]*floatDigitsMultiplier, &intPart);
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>
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
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
142ML_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.
PCLModule(int numImageInputs=0, int numImageOutputs=0, int numPCLInputs=0, int numPCLOutputs=0, bool createEnumAndNotify=false)
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)
PCLRegistration(int numInputs=2, int numOutputs=1)
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
DoubleField & getFitnessScoreFld() const
Matrix4Field & getFinalTransformationFld() const
DoubleField & getMaxCorrespondenceDistanceFld() const
#define ML_ABSTRACT_MODULE_CLASS_HEADER(className)
ML Module base class for algorithms from the Point Cloud Library (PCL).
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
long double pow(__int64 i, int value)
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition mlMatrix4.h:713