MatchersImpl.cpp
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 #include "MatchersImpl.h"
37 #include "PointMatcherPrivate.h"
38 
39 // NullMatcher
40 template<typename T>
42  const DataPoints& filteredReference)
43 {
44 
45 }
46 
47 template<typename T>
49  const DataPoints& filteredReading)
50 {
51  return Matches();
52 }
53 
54 template struct MatchersImpl<float>::NullMatcher;
55 template struct MatchersImpl<double>::NullMatcher;
56 
57 
58 
59 // KDTreeMatcher
60 template<typename T>
62  Matcher("KDTreeMatcher", KDTreeMatcher::availableParameters(), params),
63  knn(Parametrizable::get<int>("knn")),
64  epsilon(Parametrizable::get<T>("epsilon")),
65  searchType(NNSearchType(Parametrizable::get<int>("searchType"))),
66  maxDist(Parametrizable::get<T>("maxDist"))
67 {
68  LOG_INFO_STREAM("* KDTreeMatcher: initialized with knn=" << knn << ", epsilon=" << epsilon << ", searchType=" << searchType << " and maxDist=" << maxDist);
69 }
70 
71 template<typename T>
73 {
74 
75 }
76 
77 template<typename T>
79  const DataPoints& filteredReference)
80 {
81  // build and populate NNS
82  featureNNS.reset( NNS::create(filteredReference.features, filteredReference.features.rows() - 1, searchType, NNS::TOUCH_STATISTICS));
83 }
84 
85 template<typename T>
87  const DataPoints& filteredReading)
88 {
89 
90  const int pointsCount(filteredReading.features.cols());
92  typename Matches::Dists(knn, pointsCount),
93  typename Matches::Ids(knn, pointsCount)
94  );
95 
96  static_assert(NNS::InvalidIndex == Matches::InvalidId, "");
97  static_assert(NNS::InvalidValue == Matches::InvalidDist, "");
98  this->visitCounter += featureNNS->knn(filteredReading.features, matches.ids, matches.dists, knn, epsilon, NNS::ALLOW_SELF_MATCH, maxDist);
99 
100  return matches;
101 }
102 
103 template struct MatchersImpl<float>::KDTreeMatcher;
105 
106 // KDTreeVarDistMatcher
107 template<typename T>
109  Matcher("KDTreeVarDistMatcher", KDTreeVarDistMatcher::availableParameters(), params),
110  knn(Parametrizable::get<int>("knn")),
111  epsilon(Parametrizable::get<T>("epsilon")),
112  searchType(NNSearchType(Parametrizable::get<int>("searchType"))),
113  maxDistField(Parametrizable::getParamValueString("maxDistField"))
114 {
115  LOG_INFO_STREAM("* KDTreeVarDsitMatcher: initialized with knn=" << knn << ", epsilon=" << epsilon << ", searchType=" << searchType << " and maxDistField=" << maxDistField);
116 }
117 
118 template<typename T>
120 {
121 
122 }
123 
124 template<typename T>
126  const DataPoints& filteredReference)
127 {
128  // build and populate NNS
129  featureNNS.reset( NNS::create(filteredReference.features, filteredReference.features.rows() - 1, searchType, NNS::TOUCH_STATISTICS));
130 }
131 
132 template<typename T>
134  const DataPoints& filteredReading)
135 {
136 
137  const int pointsCount(filteredReading.features.cols());
139  typename Matches::Dists(knn, pointsCount),
140  typename Matches::Ids(knn, pointsCount)
141  );
142 
143  const BOOST_AUTO(maxDists, filteredReading.getDescriptorViewByName(maxDistField));
144 
145  static_assert(NNS::InvalidIndex == Matches::InvalidId, "");
146  static_assert(NNS::InvalidValue == Matches::InvalidDist, "");
147  this->visitCounter += featureNNS->knn(filteredReading.features, matches.ids, matches.dists, maxDists.transpose(), knn, epsilon, NNS::ALLOW_SELF_MATCH);
148 
149  return matches;
150 }
151 
MatchersImpl::KDTreeMatcher::~KDTreeMatcher
virtual ~KDTreeMatcher()
Definition: MatchersImpl.cpp:72
MatchersImpl::NullMatcher::findClosests
virtual Matches findClosests(const DataPoints &filteredReading)
Find the closest neighbors of filteredReading in filteredReference passed to init()
Definition: MatchersImpl.cpp:48
PointMatcher::Matches::Dists
Matrix Dists
Squared distances to closest points, dense matrix of ScalarType.
Definition: PointMatcher.h:373
compute_overlap.knn
int knn
Definition: compute_overlap.py:128
Nabo::NearestNeighbourSearch::TOUCH_STATISTICS
TOUCH_STATISTICS
Nabo::NearestNeighbourSearch::ALLOW_SELF_MATCH
ALLOW_SELF_MATCH
build_map.T
T
Definition: build_map.py:34
LOG_INFO_STREAM
#define LOG_INFO_STREAM(args)
Definition: PointMatcherPrivate.h:58
MatchersImpl::KDTreeVarDistMatcher::epsilon
const T epsilon
Definition: MatchersImpl.h:122
MatchersImpl::KDTreeMatcher::init
virtual void init(const DataPoints &filteredReference)
Init this matcher to find nearest neighbor in filteredReference.
Definition: MatchersImpl.cpp:78
PointMatcherPrivate.h
Nabo::NearestNeighbourSearch::SearchType
SearchType
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
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
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
align_sequence.params
params
Definition: align_sequence.py:13
Nabo::NearestNeighbourSearch::create
static NearestNeighbourSearch * create(const CloudType &cloud, const Index dim=std::numeric_limits< Index >::max(), const SearchType preferedType=KDTREE_LINEAR_HEAP, const unsigned creationOptionFlags=0, const Parameters &additionalParameters=Parameters())
MatchersImpl::KDTreeVarDistMatcher::knn
const int knn
Definition: MatchersImpl.h:121
MatchersImpl.h
Nabo::NearestNeighbourSearch::InvalidIndex
static constexpr Index InvalidIndex
MatchersImpl::KDTreeVarDistMatcher::~KDTreeVarDistMatcher
virtual ~KDTreeVarDistMatcher()
Definition: MatchersImpl.cpp:119
icp_advance_api.matches
matches
Definition: icp_advance_api.py:114
MatchersImpl::KDTreeMatcher::KDTreeMatcher
KDTreeMatcher(const Parameters &params=Parameters())
Definition: MatchersImpl.cpp:61
PointMatcher::Matches::Ids
IntMatrix Ids
Identifiers of closest points, dense matrix of integers.
Definition: PointMatcher.h:374
PointMatcher::DataPoints::features
Matrix features
features of points in the cloud
Definition: PointMatcher.h:331
MatchersImpl::KDTreeMatcher
Definition: MatchersImpl.h:74
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
PointMatcherSupport::get
const M::mapped_type & get(const M &m, const typename M::key_type &k)
Definition: Bibliography.cpp:57
PointMatcher::Matches::InvalidId
static constexpr int InvalidId
Definition: PointMatcher.h:377
MatchersImpl::KDTreeVarDistMatcher::searchType
const NNSearchType searchType
Definition: MatchersImpl.h:123
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::KDTreeVarDistMatcher
Definition: MatchersImpl.h:105
PointMatcher::DataPoints::getDescriptorViewByName
ConstView getDescriptorViewByName(const std::string &name) const
Get a const view on a descriptor by name, throw an exception if it does not exist.
Definition: pointmatcher/DataPoints.cpp:555
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
Nabo::NearestNeighbourSearch::InvalidValue
static constexpr T InvalidValue
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
PointMatcher::Matches::InvalidDist
static constexpr T InvalidDist
In case of too few matches the ids are filled with InvalidId.
Definition: PointMatcher.h:378
MatchersImpl::KDTreeVarDistMatcher::maxDistField
const std::string maxDistField
Definition: MatchersImpl.h:124


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