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;
93  const T maxDist;
94 
95  protected:
96  std::shared_ptr<NNS> featureNNS;
97 
98  public:
100  virtual ~KDTreeMatcher();
101  virtual void init(const DataPoints& filteredReference);
102  virtual Matches findClosests(const DataPoints& filteredReading);
103  };
104 
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;
125 
126  protected:
127  std::shared_ptr<NNS> featureNNS;
128 
129  public:
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
MatchersImpl::KDTreeMatcher::~KDTreeMatcher
virtual ~KDTreeMatcher()
Definition: MatchersImpl.cpp:72
MatchersImpl::DataPoints
PointMatcher< T >::DataPoints DataPoints
Definition: MatchersImpl.h:58
MatchersImpl::NullMatcher::findClosests
virtual Matches findClosests(const DataPoints &filteredReading)
Find the closest neighbors of filteredReading in filteredReference passed to init()
Definition: MatchersImpl.cpp:48
MatchersImpl::KDTreeMatcher::featureNNS
std::shared_ptr< NNS > featureNNS
Definition: MatchersImpl.h:96
MatchersImpl::ParameterDoc
Parametrizable::ParameterDoc ParameterDoc
Definition: MatchersImpl.h:52
MatchersImpl::Matcher
PointMatcher< T >::Matcher Matcher
Definition: MatchersImpl.h:59
MatchersImpl::Parameters
Parametrizable::Parameters Parameters
Definition: MatchersImpl.h:51
build_map.T
T
Definition: build_map.py:34
MatchersImpl::KDTreeVarDistMatcher::epsilon
const T epsilon
Definition: MatchersImpl.h:122
MatchersImpl::ParametersDoc
Parametrizable::ParametersDoc ParametersDoc
Definition: MatchersImpl.h:53
MatchersImpl::KDTreeVarDistMatcher::description
static const std::string description()
Definition: MatchersImpl.h:107
MatchersImpl::KDTreeMatcher::init
virtual void init(const DataPoints &filteredReference)
Init this matcher to find nearest neighbor in filteredReference.
Definition: MatchersImpl.cpp:78
Nabo::NearestNeighbourSearch::SearchType
SearchType
MatchersImpl::Parametrizable
PointMatcherSupport::Parametrizable Parametrizable
Definition: MatchersImpl.h:49
MatchersImpl::KDTreeMatcher::epsilon
const T epsilon
Definition: MatchersImpl.h:91
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
MatchersImpl::KDTreeVarDistMatcher::init
virtual void init(const DataPoints &filteredReference)
Init this matcher to find nearest neighbor in filteredReference.
Definition: MatchersImpl.cpp:125
MatchersImpl::NullMatcher::description
static const std::string description()
Definition: MatchersImpl.h:64
PointMatcher::Matcher
A matcher links points in the reading to points in the reference.
Definition: PointMatcher.h:474
MatchersImpl::Matches
PointMatcher< T >::Matches Matches
Definition: MatchersImpl.h:60
testing::internal::string
::std::string string
Definition: gtest.h:1979
MatchersImpl
Definition: MatchersImpl.h:47
MatchersImpl::NNS
Nabo::NearestNeighbourSearch< T > NNS
Definition: MatchersImpl.h:55
nabo.h
Nabo::NearestNeighbourSearch
MatchersImpl::NullMatcher::init
virtual void init(const DataPoints &filteredReference)
Init this matcher to find nearest neighbor in filteredReference.
Definition: MatchersImpl.cpp:41
MatchersImpl::KDTreeMatcher::searchType
const NNSearchType searchType
Definition: MatchersImpl.h:92
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
MatchersImpl::KDTreeVarDistMatcher::knn
const int knn
Definition: MatchersImpl.h:121
MatchersImpl::KDTreeVarDistMatcher::~KDTreeVarDistMatcher
virtual ~KDTreeVarDistMatcher()
Definition: MatchersImpl.cpp:119
MatchersImpl::KDTreeMatcher::KDTreeMatcher
KDTreeMatcher(const Parameters &params=Parameters())
Definition: MatchersImpl.cpp:61
MatchersImpl::KDTreeMatcher
Definition: MatchersImpl.h:74
PointMatcher::Matches
Result of the data-association step (Matcher::findClosests), before outlier rejection.
Definition: PointMatcher.h:371
MatchersImpl::KDTreeMatcher::availableParameters
static const ParametersDoc availableParameters()
Definition: MatchersImpl.h:80
PointMatcherSupport::Parametrizable
The superclass of classes that are constructed using generic parameters. This class provides the para...
Definition: Parametrizable.h:141
MatchersImpl::KDTreeVarDistMatcher::searchType
const NNSearchType searchType
Definition: MatchersImpl.h:123
PointMatcherSupport::Parametrizable::ParameterDoc
The documentation of a parameter.
Definition: Parametrizable.h:160
MatchersImpl::KDTreeMatcher::description
static const std::string description()
Definition: MatchersImpl.h:76
MatchersImpl::KDTreeVarDistMatcher::availableParameters
static const ParametersDoc availableParameters()
Definition: MatchersImpl.h:111
MatchersImpl::KDTreeVarDistMatcher::findClosests
virtual Matches findClosests(const DataPoints &filteredReading)
Find the closest neighbors of filteredReading in filteredReference passed to init()
Definition: MatchersImpl.cpp:133
MatchersImpl::NNSearchType
NNS::SearchType NNSearchType
Definition: MatchersImpl.h:56
MatchersImpl::KDTreeVarDistMatcher::featureNNS
std::shared_ptr< NNS > featureNNS
Definition: MatchersImpl.h:127
MatchersImpl::NullMatcher::NullMatcher
NullMatcher()
Definition: MatchersImpl.h:69
MatchersImpl::KDTreeVarDistMatcher
Definition: MatchersImpl.h:105
PointMatcher.h
public interface
MatchersImpl::P
PointMatcherSupport::Parametrizable P
Definition: MatchersImpl.h:50
MatchersImpl::NullMatcher
Definition: MatchersImpl.h:62
MatchersImpl::KDTreeMatcher::knn
const int knn
Definition: MatchersImpl.h:90
MatchersImpl::KDTreeVarDistMatcher::KDTreeVarDistMatcher
KDTreeVarDistMatcher(const Parameters &params=Parameters())
Definition: MatchersImpl.cpp:108
MatchersImpl::KDTreeMatcher::findClosests
virtual Matches findClosests(const DataPoints &filteredReading)
Find the closest neighbors of filteredReading in filteredReference passed to init()
Definition: MatchersImpl.cpp:86
PointMatcherSupport::Parametrizable::Parameters
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Definition: Parametrizable.h:199
MatchersImpl::KDTreeMatcher::maxDist
const T maxDist
Definition: MatchersImpl.h:93
MatchersImpl::KDTreeVarDistMatcher::maxDistField
const std::string maxDistField
Definition: MatchersImpl.h:124


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:09