InspectorsImpl.h
Go to the documentation of this file.
1 // kate: replace-tabs off; indent-width 4; indent-mode normal
2 // vim: ts=4:sw=4:noexpandtab
3 /*
4 
5 Copyright (c) 2010--2012,
6 François Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
7 You can contact the authors at <f dot pomerleau at gmail dot com> and
8 <stephane at magnenat dot net>
9 
10 All rights reserved.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of the <organization> nor the
20  names of its contributors may be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef __POINTMATCHER_INSPECTORS_H
37 #define __POINTMATCHER_INSPECTORS_H
38 
39 #include "PointMatcher.h"
40 #include "Histogram.h"
41 
42 template<typename T>
44 {
50 
57  typedef typename PointMatcher<T>::Matrix Matrix;
58 
59  // Clearer name when no inspector is required
60  struct NullInspector: public Inspector
61  {
62  inline static const std::string description()
63  {
64  return "Does nothing.";
65  }
66 
67  // This constructor is not required. It make the attribute className == "NullInspector" instead of 'unknown'
68  NullInspector() : Inspector("NullInspector", ParametersDoc(), Parameters()) {}
69 
70  };
71 
73  {
74  inline static const std::string description()
75  {
76  return "Keep statistics on performance.";
77  }
78  inline static const ParametersDoc availableParameters()
79  {
80  return {
81  {"baseFileName", "base file name for the statistics files (if empty, disabled)", ""},
82  {"dumpPerfOnExit", "dump performance statistics to stderr on exit", "0"},
83  {"dumpStats", "dump the statistics on first and last step", "0"}
84  };
85  }
86 
88  // Note: Prefix boolean variables with 'b' to avoid conflicts
89  // with similarly named functions.
90  const bool bDumpPerfOnExit;
91  const bool bDumpStats;
92 
93  protected:
95  typedef std::map<std::string, Histogram> HistogramMap;
97 
98  public:
101 
102  virtual void addStat(const std::string& name, double data);
103  virtual void dumpStats(std::ostream& stream);
104  virtual void dumpStatsHeader(std::ostream& stream);
105  };
106 
108  {
109 
110  protected:
111  virtual std::ostream* openStream(const std::string& role) = 0;
112  virtual std::ostream* openStream(const std::string& role, const size_t iterationNumber) = 0;
113  virtual void closeStream(std::ostream* stream) = 0;
114  void dumpDataPoints(const DataPoints& data, std::ostream& stream);
115  void dumpMeshNodes(const DataPoints& data, std::ostream& stream);
116  void dumpDataLinks(const DataPoints& ref, const DataPoints& reading, const Matches& matches, const OutlierWeights& featureOutlierWeights, std::ostream& stream);
117 
118  std::ostream* streamIter;
119  const bool bDumpIterationInfo;
120  const bool bDumpDataLinks;
121  const bool bDumpReading;
122  const bool bDumpReference;
123  const bool bWriteBinary;
124 
125  public:
126  AbstractVTKInspector(const std::string& className, const ParametersDoc paramsDoc, const Parameters& params);
127  virtual void init() {};
128  virtual void dumpDataPoints(const DataPoints& cloud, const std::string& name);
129  virtual void dumpMeshNodes(const DataPoints& cloud, const std::string& name);
130  virtual void dumpIteration(const size_t iterationNumber, const TransformationParameters& parameters, const DataPoints& filteredReference, const DataPoints& reading, const Matches& matches, const OutlierWeights& outlierWeights, const TransformationCheckers& transformationCheckers);
131  virtual void finish(const size_t iterationCount);
132 
133  private:
134  void buildGenericAttributeStream(std::ostream& stream, const std::string& attribute, const std::string& nameTag, const DataPoints& cloud, const int forcedDim);
135 
136  void buildScalarStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
137  void buildScalarStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
138 
139  void buildNormalStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
140  void buildNormalStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
141 
142  void buildVectorStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
143  void buildVectorStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
144 
145  void buildTensorStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
146  void buildTensorStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
147 
148  void buildColorStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
149 
150  void buildTimeStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
151 
152 
153 
154  Matrix padWithZeros(const Matrix m, const int expectedRow, const int expectedCols);
155  Matrix padWithOnes(const Matrix m, const int expectedRow, const int expectedCols);
156  };
157 
159  {
160  inline static const std::string description()
161  {
162  return "Dump the different steps into VTK files.";
163  }
164  inline static const ParametersDoc availableParameters()
165  {
166  return {
167  {"baseFileName", "base file name for the VTK files ", "point-matcher-output"},
168  {"dumpPerfOnExit", "dump performance statistics to stderr on exit", "0"},
169  {"dumpStats", "dump the statistics on first and last step", "0"},
170  {"dumpIterationInfo", "dump iteration info", "0"},
171  {"dumpDataLinks", "dump data links at each iteration", "0" },
172  {"dumpReading", "dump the reading cloud at each iteration", "0"},
173  {"dumpReference", "dump the reference cloud at each iteration", "0"},
174  {"writeBinary", "write binary VTK files", "0"}
175  };
176  }
177 
179  const bool bDumpIterationInfo;
180  const bool bDumpDataLinks;
181  const bool bDumpReading;
182  const bool bDumpReference;
183 
184  protected:
185  virtual std::ostream* openStream(const std::string& role);
186  virtual std::ostream* openStream(const std::string& role, const size_t iterationCount);
187  virtual void closeStream(std::ostream* stream);
188 
189  public:
191  virtual void init();
192  virtual void finish(const size_t iterationCount);
193  };
194 }; // InspectorsImpl
195 
196 #endif // __POINTMATCHER_INSPECTORS_H
InspectorsImpl::AbstractVTKInspector::bDumpReference
const bool bDumpReference
Definition: InspectorsImpl.h:122
InspectorsImpl::AbstractVTKInspector::dumpDataLinks
void dumpDataLinks(const DataPoints &ref, const DataPoints &reading, const Matches &matches, const OutlierWeights &featureOutlierWeights, std::ostream &stream)
Definition: InspectorsImpl.cpp:286
InspectorsImpl::DataPoints
PointMatcher< T >::DataPoints DataPoints
Definition: InspectorsImpl.h:52
InspectorsImpl::AbstractVTKInspector::buildScalarStream
void buildScalarStream(std::ostream &stream, const std::string &name, const DataPoints &ref, const DataPoints &reading)
Definition: InspectorsImpl.cpp:532
InspectorsImpl::AbstractVTKInspector::closeStream
virtual void closeStream(std::ostream *stream)=0
InspectorsImpl::AbstractVTKInspector::bDumpDataLinks
const bool bDumpDataLinks
Definition: InspectorsImpl.h:120
InspectorsImpl::AbstractVTKInspector::dumpIteration
virtual void dumpIteration(const size_t iterationNumber, const TransformationParameters &parameters, const DataPoints &filteredReference, const DataPoints &reading, const Matches &matches, const OutlierWeights &outlierWeights, const TransformationCheckers &transformationCheckers)
Dump the state of a given iteration.
Definition: InspectorsImpl.cpp:385
InspectorsImpl::AbstractVTKInspector::padWithZeros
Matrix padWithZeros(const Matrix m, const int expectedRow, const int expectedCols)
Definition: InspectorsImpl.cpp:666
InspectorsImpl::AbstractVTKInspector::bDumpReading
const bool bDumpReading
Definition: InspectorsImpl.h:121
InspectorsImpl::PerformanceInspector
Definition: InspectorsImpl.h:72
PointMatcher::OutlierWeights
Matrix OutlierWeights
Weights of the associations between the points in Matches and the points in the reference.
Definition: PointMatcher.h:397
InspectorsImpl::Inspector
PointMatcher< T >::Inspector Inspector
Definition: InspectorsImpl.h:51
InspectorsImpl::AbstractVTKInspector::streamIter
std::ostream * streamIter
Definition: InspectorsImpl.h:118
icp_customized.name
string name
Definition: icp_customized.py:45
InspectorsImpl::AbstractVTKInspector::bWriteBinary
const bool bWriteBinary
Definition: InspectorsImpl.h:123
InspectorsImpl::AbstractVTKInspector::buildGenericAttributeStream
void buildGenericAttributeStream(std::ostream &stream, const std::string &attribute, const std::string &nameTag, const DataPoints &cloud, const int forcedDim)
Definition: InspectorsImpl.cpp:453
InspectorsImpl::VTKFileInspector::bDumpReference
const bool bDumpReference
Definition: InspectorsImpl.h:182
InspectorsImpl::VTKFileInspector::bDumpReading
const bool bDumpReading
Definition: InspectorsImpl.h:181
InspectorsImpl::PerformanceInspector::Histogram
PointMatcherSupport::Histogram< double > Histogram
Definition: InspectorsImpl.h:94
InspectorsImpl::Matches
PointMatcher< T >::Matches Matches
Definition: InspectorsImpl.h:53
InspectorsImpl::ParametersDoc
Parametrizable::ParametersDoc ParametersDoc
Definition: InspectorsImpl.h:49
InspectorsImpl::VTKFileInspector::description
static const std::string description()
Definition: InspectorsImpl.h:160
InspectorsImpl::PerformanceInspector::HistogramMap
std::map< std::string, Histogram > HistogramMap
Definition: InspectorsImpl.h:95
InspectorsImpl::AbstractVTKInspector
Definition: InspectorsImpl.h:107
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
InspectorsImpl::VTKFileInspector::availableParameters
static const ParametersDoc availableParameters()
Definition: InspectorsImpl.h:164
testing::internal::string
::std::string string
Definition: gtest.h:1979
InspectorsImpl::AbstractVTKInspector::dumpDataPoints
void dumpDataPoints(const DataPoints &data, std::ostream &stream)
Definition: InspectorsImpl.cpp:159
InspectorsImpl::PerformanceInspector::bDumpPerfOnExit
const bool bDumpPerfOnExit
Definition: InspectorsImpl.h:90
InspectorsImpl::VTKFileInspector::closeStream
virtual void closeStream(std::ostream *stream)
Definition: InspectorsImpl.cpp:782
InspectorsImpl::NullInspector::description
static const std::string description()
Definition: InspectorsImpl.h:62
InspectorsImpl::VTKFileInspector::VTKFileInspector
VTKFileInspector(const Parameters &params=Parameters())
Definition: InspectorsImpl.cpp:715
InspectorsImpl::VTKFileInspector::init
virtual void init()
Start a new ICP operation or sequence.
Definition: InspectorsImpl.cpp:726
InspectorsImpl::Parametrizable
PointMatcherSupport::Parametrizable Parametrizable
Definition: InspectorsImpl.h:45
InspectorsImpl::ParameterDoc
Parametrizable::ParameterDoc ParameterDoc
Definition: InspectorsImpl.h:48
InspectorsImpl::PerformanceInspector::stats
HistogramMap stats
Definition: InspectorsImpl.h:96
InspectorsImpl::Matrix
PointMatcher< T >::Matrix Matrix
Definition: InspectorsImpl.h:57
InspectorsImpl::PerformanceInspector::description
static const std::string description()
Definition: InspectorsImpl.h:74
InspectorsImpl::AbstractVTKInspector::openStream
virtual std::ostream * openStream(const std::string &role)=0
InspectorsImpl::OutlierWeights
PointMatcher< T >::OutlierWeights OutlierWeights
Definition: InspectorsImpl.h:54
InspectorsImpl::VTKFileInspector::baseFileName
const std::string baseFileName
Definition: InspectorsImpl.h:178
PointMatcherSupport::Parametrizable::ParametersDoc
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
Definition: Parametrizable.h:187
align_sequence.params
params
Definition: align_sequence.py:13
InspectorsImpl::PerformanceInspector::dumpStats
virtual void dumpStats(std::ostream &stream)
Dump all statistics in CSV format.
Definition: InspectorsImpl.cpp:83
InspectorsImpl::PerformanceInspector::baseFileName
const std::string baseFileName
Definition: InspectorsImpl.h:87
InspectorsImpl::AbstractVTKInspector::finish
virtual void finish(const size_t iterationCount)
Tell the inspector the ICP operation is completed.
Definition: InspectorsImpl.cpp:706
PointMatcherSupport::Parametrizable::parameters
Parameters parameters
parameters with their values encoded in string
Definition: Parametrizable.h:204
icp_advance_api.matches
matches
Definition: icp_advance_api.py:114
icp.data
data
Definition: icp.py:50
InspectorsImpl::TransformationCheckers
PointMatcher< T >::TransformationCheckers TransformationCheckers
Definition: InspectorsImpl.h:56
PointMatcher::Matrix
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
InspectorsImpl::VTKFileInspector::bDumpDataLinks
const bool bDumpDataLinks
Definition: InspectorsImpl.h:180
icp.ref
ref
Definition: icp.py:49
InspectorsImpl::AbstractVTKInspector::buildColorStream
void buildColorStream(std::ostream &stream, const std::string &name, const DataPoints &cloud)
Definition: InspectorsImpl.cpp:524
InspectorsImpl::AbstractVTKInspector::init
virtual void init()
Start a new ICP operation or sequence.
Definition: InspectorsImpl.h:127
InspectorsImpl::PerformanceInspector::PerformanceInspector
PerformanceInspector(const std::string &className, const ParametersDoc paramsDoc, const Parameters &params)
Definition: InspectorsImpl.cpp:52
Histogram.h
InspectorsImpl::PerformanceInspector::availableParameters
static const ParametersDoc availableParameters()
Definition: InspectorsImpl.h:78
InspectorsImpl::PerformanceInspector::dumpStatsHeader
virtual void dumpStatsHeader(std::ostream &stream)
Dump header for all statistics.
Definition: InspectorsImpl.cpp:97
PointMatcher::Matches
Result of the data-association step (Matcher::findClosests), before outlier rejection.
Definition: PointMatcher.h:371
PointMatcherSupport::Parametrizable
The superclass of classes that are constructed using generic parameters. This class provides the para...
Definition: Parametrizable.h:141
InspectorsImpl::PerformanceInspector::addStat
virtual void addStat(const std::string &name, double data)
Add a value for statistics name, create it if new.
Definition: InspectorsImpl.cpp:70
InspectorsImpl::AbstractVTKInspector::AbstractVTKInspector
AbstractVTKInspector(const std::string &className, const ParametersDoc paramsDoc, const Parameters &params)
Definition: InspectorsImpl.cpp:138
InspectorsImpl::AbstractVTKInspector::padWithOnes
Matrix padWithOnes(const Matrix m, const int expectedRow, const int expectedCols)
Definition: InspectorsImpl.cpp:686
InspectorsImpl::AbstractVTKInspector::buildTimeStream
void buildTimeStream(std::ostream &stream, const std::string &name, const DataPoints &cloud)
Definition: InspectorsImpl.cpp:628
PointMatcherSupport::Parametrizable::ParameterDoc
The documentation of a parameter.
Definition: Parametrizable.h:160
InspectorsImpl::NullInspector::NullInspector
NullInspector()
Definition: InspectorsImpl.h:68
InspectorsImpl::AbstractVTKInspector::buildVectorStream
void buildVectorStream(std::ostream &stream, const std::string &name, const DataPoints &ref, const DataPoints &reading)
Definition: InspectorsImpl.cpp:581
PointMatcher::TransformationCheckers
A chain of TransformationChecker.
Definition: PointMatcher.h:611
InspectorsImpl::VTKFileInspector
Definition: InspectorsImpl.h:158
PointMatcher::Inspector
An inspector allows to log data at the different steps, for analysis.
Definition: PointMatcher.h:624
InspectorsImpl::TransformationParameters
PointMatcher< T >::TransformationParameters TransformationParameters
Definition: InspectorsImpl.h:55
InspectorsImpl
Definition: InspectorsImpl.h:43
InspectorsImpl::AbstractVTKInspector::bDumpIterationInfo
const bool bDumpIterationInfo
Definition: InspectorsImpl.h:119
InspectorsImpl::AbstractVTKInspector::buildTensorStream
void buildTensorStream(std::ostream &stream, const std::string &name, const DataPoints &ref, const DataPoints &reading)
Definition: InspectorsImpl.cpp:605
InspectorsImpl::P
PointMatcherSupport::Parametrizable P
Definition: InspectorsImpl.h:46
InspectorsImpl::VTKFileInspector::openStream
virtual std::ostream * openStream(const std::string &role)
Definition: InspectorsImpl.cpp:750
PointMatcher.h
public interface
InspectorsImpl::AbstractVTKInspector::buildNormalStream
void buildNormalStream(std::ostream &stream, const std::string &name, const DataPoints &ref, const DataPoints &reading)
Definition: InspectorsImpl.cpp:557
PointMatcherSupport::Histogram
Definition: Histogram.h:46
InspectorsImpl::VTKFileInspector::bDumpIterationInfo
const bool bDumpIterationInfo
Definition: InspectorsImpl.h:179
InspectorsImpl::PerformanceInspector::bDumpStats
const bool bDumpStats
Definition: InspectorsImpl.h:91
InspectorsImpl::NullInspector
Definition: InspectorsImpl.h:60
PointMatcherSupport::Parametrizable::className
const std::string className
name of the class
Definition: Parametrizable.h:202
InspectorsImpl::AbstractVTKInspector::dumpMeshNodes
void dumpMeshNodes(const DataPoints &data, std::ostream &stream)
Definition: InspectorsImpl.cpp:238
InspectorsImpl::VTKFileInspector::finish
virtual void finish(const size_t iterationCount)
Tell the inspector the ICP operation is completed.
Definition: InspectorsImpl.cpp:743
PointMatcherSupport::Parametrizable::Parameters
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Definition: Parametrizable.h:199
compute_overlap.reading
reading
Definition: compute_overlap.py:70
PointMatcher::TransformationParameters
Matrix TransformationParameters
A matrix holding the parameters a transformation.
Definition: PointMatcher.h:182
InspectorsImpl::Parameters
Parametrizable::Parameters Parameters
Definition: InspectorsImpl.h:47


libpointmatcher
Author(s):
autogenerated on Mon Jan 1 2024 03:24:43