MatchersImpl.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_MATCHERS_H
37 #define __POINTMATCHER_MATCHERS_H
38 
39 #include "PointMatcher.h"
40 
41 #include "nabo/nabo.h"
42 #if NABO_VERSION_INT < 10007
43  #error "You need libnabo version 1.0.7 or greater"
44 #endif
45 
46 template<typename T>
48 {
54 
56  typedef typename NNS::SearchType NNSearchType;
57 
61 
62  struct NullMatcher: public Matcher
63  {
64  inline static const std::string description()
65  {
66  return "Does nothing, returns no match.";
67  }
68 
69  NullMatcher() : Matcher("NullMatcher", ParametersDoc(), Parameters()) {}
70  virtual void init(const DataPoints& filteredReference);
71  virtual Matches findClosests(const DataPoints& filteredReading);
72  };
73 
74  struct KDTreeMatcher: public Matcher
75  {
76  inline static const std::string description()
77  {
78  return "This matcher matches a point from the reading to its closest neighbors in the reference.";
79  }
80  inline static const ParametersDoc availableParameters()
81  {
82  return {
83  {"knn", "number of nearest neighbors to consider it the reference", "1", "1", "2147483647", &P::Comp<unsigned>},
84  {"epsilon", "approximation to use for the nearest-neighbor search", "0", "0", "inf", &P::Comp<T>},
85  {"searchType", "Nabo search type. 0: brute force, check distance to every point in the data (very slow), 1: kd-tree with linear heap, good for small knn (~up to 30) and 2: kd-tree with tree heap, good for large knn (~from 30)", "1", "0", "2", &P::Comp<unsigned>},
86  {"maxDist", "maximum distance to consider for neighbors", "inf", "0", "inf", &P::Comp<T>}
87  };
88  }
89 
90  const int knn;
91  const T epsilon;
92  const NNSearchType searchType;
93  const T maxDist;
94 
95  protected:
96  std::shared_ptr<NNS> featureNNS;
97 
98  public:
99  KDTreeMatcher(const Parameters& params = Parameters());
100  virtual ~KDTreeMatcher();
101  virtual void init(const DataPoints& filteredReference);
102  virtual Matches findClosests(const DataPoints& filteredReading);
103  };
104 
105  struct KDTreeVarDistMatcher: public Matcher
106  {
107  inline static const std::string description()
108  {
109  return "This matcher matches a point from the reading to its closest neighbors in the reference. A maximum search radius per point can be defined.";
110  }
111  inline static const ParametersDoc availableParameters()
112  {
113  return {
114  {"knn", "number of nearest neighbors to consider it the reference", "1", "1", "2147483647", &P::Comp<unsigned>},
115  {"epsilon", "approximation to use for the nearest-neighbor search", "0", "0", "inf", &P::Comp<T>},
116  {"searchType", "Nabo search type. 0: brute force, check distance to every point in the data (very slow), 1: kd-tree with linear heap, good for small knn (~up to 30) and 2: kd-tree with tree heap, good for large knn (~from 30)", "1", "0", "2", &P::Comp<unsigned>},
117  {"maxDistField", "descriptor field name used to set a maximum distance to consider for neighbors per point", "maxSearchDist"}
118  };
119  }
120 
121  const int knn;
122  const T epsilon;
123  const NNSearchType searchType;
125 
126  protected:
127  std::shared_ptr<NNS> featureNNS;
128 
129  public:
130  KDTreeVarDistMatcher(const Parameters& params = Parameters());
131  virtual ~KDTreeVarDistMatcher();
132  virtual void init(const DataPoints& filteredReference);
133  virtual Matches findClosests(const DataPoints& filteredReading);
134  };
135 
136 }; // MatchersImpl
137 
138 #endif // __POINTMATCHER_MATCHERS_H
A matcher links points in the reading to points in the reference.
Definition: PointMatcher.h:473
static const std::string description()
Definition: MatchersImpl.h:76
public interface
Parametrizable::ParametersDoc ParametersDoc
Definition: MatchersImpl.h:53
static const ParametersDoc availableParameters()
Definition: MatchersImpl.h:80
std::shared_ptr< NNS > featureNNS
Definition: MatchersImpl.h:127
::std::string string
Definition: gtest.h:1979
Nabo::NearestNeighbourSearch< T > NNS
Definition: MatchersImpl.h:55
std::shared_ptr< NNS > featureNNS
Definition: MatchersImpl.h:96
NNS::SearchType NNSearchType
Definition: MatchersImpl.h:56
static const ParametersDoc availableParameters()
Definition: MatchersImpl.h:111
Parametrizable::ParameterDoc ParameterDoc
Definition: MatchersImpl.h:52
PointMatcher< T >::DataPoints DataPoints
Definition: MatchersImpl.h:58
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Parametrizable::Parameters Parameters
Definition: MatchersImpl.h:51
const NNSearchType searchType
Definition: MatchersImpl.h:92
PointMatcherSupport::Parametrizable Parametrizable
Definition: MatchersImpl.h:49
Result of the data-association step (Matcher::findClosests), before outlier rejection.
Definition: PointMatcher.h:371
PointMatcher< T >::Matches Matches
Definition: MatchersImpl.h:60
The documentation of a parameter.
PointMatcherSupport::Parametrizable P
Definition: MatchersImpl.h:50
The superclass of classes that are constructed using generic parameters. This class provides the para...
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
PointMatcher< T >::Matcher Matcher
Definition: MatchersImpl.h:59
virtual Matches findClosests(const DataPoints &filteredReading)
Find the closest neighbors of filteredReading in filteredReference passed to init() ...
static const std::string description()
Definition: MatchersImpl.h:107
static const std::string description()
Definition: MatchersImpl.h:64
virtual void init(const DataPoints &filteredReference)
Init this matcher to find nearest neighbor in filteredReference.


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:02