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  const unsigned precision;
125 
126  public:
127  AbstractVTKInspector(const std::string& className, const ParametersDoc paramsDoc, const Parameters& params);
128  virtual void init() {};
129  virtual void dumpDataPoints(const DataPoints& cloud, const std::string& name);
130  virtual void dumpMeshNodes(const DataPoints& cloud, const std::string& name);
131  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);
132  virtual void finish(const size_t iterationCount);
133 
134  private:
135  void buildGenericAttributeStream(std::ostream& stream, const std::string& attribute, const std::string& nameTag, const DataPoints& cloud, const int forcedDim);
136 
137  void buildScalarStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
138  void buildScalarStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
139 
140  void buildNormalStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
141  void buildNormalStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
142 
143  void buildVectorStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
144  void buildVectorStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
145 
146  void buildTensorStream(std::ostream& stream, const std::string& name, const DataPoints& ref, const DataPoints& reading);
147  void buildTensorStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
148 
149  void buildColorStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
150 
151  void buildTimeStream(std::ostream& stream, const std::string& name, const DataPoints& cloud);
152 
153 
154 
155  Matrix padWithZeros(const Matrix m, const int expectedRow, const int expectedCols);
156  Matrix padWithOnes(const Matrix m, const int expectedRow, const int expectedCols);
157  };
158 
160  {
161  inline static const std::string description()
162  {
163  return "Dump the different steps into VTK files.";
164  }
165  inline static const ParametersDoc availableParameters()
166  {
167  return {
168  {"baseFileName", "base file name for the VTK files ", "point-matcher-output"},
169  {"dumpPerfOnExit", "dump performance statistics to stderr on exit", "0"},
170  {"dumpStats", "dump the statistics on first and last step", "0"},
171  {"dumpIterationInfo", "dump iteration info", "0"},
172  {"dumpDataLinks", "dump data links at each iteration", "0" },
173  {"dumpReading", "dump the reading cloud at each iteration", "0"},
174  {"dumpReference", "dump the reference cloud at each iteration", "0"},
175  {"writeBinary", "write binary VTK files", "0"},
176  {"precision", "default output precision", "7"}
177  };
178  }
179 
181  const bool bDumpIterationInfo;
182  const bool bDumpDataLinks;
183  const bool bDumpReading;
184  const bool bDumpReference;
185  const unsigned precision;
186 
187  protected:
188  virtual std::ostream* openStream(const std::string& role);
189  virtual std::ostream* openStream(const std::string& role, const size_t iterationCount);
190  virtual void closeStream(std::ostream* stream);
191 
192  public:
194  virtual void init();
195  virtual void finish(const size_t iterationCount);
196  };
197 }; // InspectorsImpl
198 
199 #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:287
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:534
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:387
InspectorsImpl::AbstractVTKInspector::padWithZeros
Matrix padWithZeros(const Matrix m, const int expectedRow, const int expectedCols)
Definition: InspectorsImpl.cpp:668
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:455
InspectorsImpl::VTKFileInspector::bDumpReference
const bool bDumpReference
Definition: InspectorsImpl.h:184
InspectorsImpl::VTKFileInspector::bDumpReading
const bool bDumpReading
Definition: InspectorsImpl.h:183
InspectorsImpl::VTKFileInspector::precision
const unsigned precision
Definition: InspectorsImpl.h:185
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:161
InspectorsImpl::PerformanceInspector::HistogramMap
std::map< std::string, Histogram > HistogramMap
Definition: InspectorsImpl.h:95
InspectorsImpl::AbstractVTKInspector::precision
const unsigned precision
Definition: InspectorsImpl.h:124
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:165
testing::internal::string
::std::string string
Definition: gtest.h:1979
InspectorsImpl::AbstractVTKInspector::dumpDataPoints
void dumpDataPoints(const DataPoints &data, std::ostream &stream)
Definition: InspectorsImpl.cpp:160
InspectorsImpl::PerformanceInspector::bDumpPerfOnExit
const bool bDumpPerfOnExit
Definition: InspectorsImpl.h:90
InspectorsImpl::VTKFileInspector::closeStream
virtual void closeStream(std::ostream *stream)
Definition: InspectorsImpl.cpp:785
InspectorsImpl::NullInspector::description
static const std::string description()
Definition: InspectorsImpl.h:62
InspectorsImpl::VTKFileInspector::VTKFileInspector
VTKFileInspector(const Parameters &params=Parameters())
Definition: InspectorsImpl.cpp:717
InspectorsImpl::VTKFileInspector::init
virtual void init()
Start a new ICP operation or sequence.
Definition: InspectorsImpl.cpp:729
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:180
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:708
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:182
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:526
InspectorsImpl::AbstractVTKInspector::init
virtual void init()
Start a new ICP operation or sequence.
Definition: InspectorsImpl.h:128
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:688
InspectorsImpl::AbstractVTKInspector::buildTimeStream
void buildTimeStream(std::ostream &stream, const std::string &name, const DataPoints &cloud)
Definition: InspectorsImpl.cpp:630
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:583
PointMatcher::TransformationCheckers
A chain of TransformationChecker.
Definition: PointMatcher.h:612
InspectorsImpl::VTKFileInspector
Definition: InspectorsImpl.h:159
PointMatcher::Inspector
An inspector allows to log data at the different steps, for analysis.
Definition: PointMatcher.h:625
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:607
InspectorsImpl::P
PointMatcherSupport::Parametrizable P
Definition: InspectorsImpl.h:46
InspectorsImpl::VTKFileInspector::openStream
virtual std::ostream * openStream(const std::string &role)
Definition: InspectorsImpl.cpp:753
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:559
PointMatcherSupport::Histogram
Definition: Histogram.h:46
InspectorsImpl::VTKFileInspector::bDumpIterationInfo
const bool bDumpIterationInfo
Definition: InspectorsImpl.h:181
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:239
InspectorsImpl::VTKFileInspector::finish
virtual void finish(const size_t iterationCount)
Tell the inspector the ICP operation is completed.
Definition: InspectorsImpl.cpp:746
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 Sep 16 2024 02:24:09