Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "MatchersImpl.h"
00037 #include "PointMatcherPrivate.h"
00038
00039
00040 template<typename T>
00041 void MatchersImpl<T>::NullMatcher::init(
00042 const DataPoints& filteredReference)
00043 {
00044
00045 }
00046
00047 template<typename T>
00048 typename PointMatcher<T>::Matches MatchersImpl<T>::NullMatcher::findClosests(
00049 const DataPoints& filteredReading)
00050 {
00051 return Matches();
00052 }
00053
00054 template struct MatchersImpl<float>::NullMatcher;
00055 template struct MatchersImpl<double>::NullMatcher;
00056
00057
00058
00059
00060 template<typename T>
00061 MatchersImpl<T>::KDTreeMatcher::KDTreeMatcher(const Parameters& params):
00062 Matcher("KDTreeMatcher", KDTreeMatcher::availableParameters(), params),
00063 knn(Parametrizable::get<int>("knn")),
00064 epsilon(Parametrizable::get<T>("epsilon")),
00065 searchType(NNSearchType(Parametrizable::get<int>("searchType"))),
00066 maxDist(Parametrizable::get<T>("maxDist"))
00067 {
00068 LOG_INFO_STREAM("* KDTreeMatcher: initialized with knn=" << knn << ", epsilon=" << epsilon << ", searchType=" << searchType << " and maxDist=" << maxDist);
00069 }
00070
00071 template<typename T>
00072 MatchersImpl<T>::KDTreeMatcher::~KDTreeMatcher()
00073 {
00074
00075 }
00076
00077 template<typename T>
00078 void MatchersImpl<T>::KDTreeMatcher::init(
00079 const DataPoints& filteredReference)
00080 {
00081
00082 featureNNS.reset( NNS::create(filteredReference.features, filteredReference.features.rows() - 1, searchType, NNS::TOUCH_STATISTICS));
00083 }
00084
00085 template<typename T>
00086 typename PointMatcher<T>::Matches MatchersImpl<T>::KDTreeMatcher::findClosests(
00087 const DataPoints& filteredReading)
00088 {
00089
00090 const int pointsCount(filteredReading.features.cols());
00091 Matches matches(
00092 typename Matches::Dists(knn, pointsCount),
00093 typename Matches::Ids(knn, pointsCount)
00094 );
00095
00096 this->visitCounter += featureNNS->knn(filteredReading.features, matches.ids, matches.dists, knn, epsilon, NNS::ALLOW_SELF_MATCH, maxDist);
00097
00098 return matches;
00099 }
00100
00101 template struct MatchersImpl<float>::KDTreeMatcher;
00102 template struct MatchersImpl<double>::KDTreeMatcher;
00103
00104
00105 template<typename T>
00106 MatchersImpl<T>::KDTreeVarDistMatcher::KDTreeVarDistMatcher(const Parameters& params):
00107 Matcher("KDTreeVarDistMatcher", KDTreeVarDistMatcher::availableParameters(), params),
00108 knn(Parametrizable::get<int>("knn")),
00109 epsilon(Parametrizable::get<T>("epsilon")),
00110 searchType(NNSearchType(Parametrizable::get<int>("searchType"))),
00111 maxDistField(Parametrizable::getParamValueString("maxDistField"))
00112 {
00113 LOG_INFO_STREAM("* KDTreeVarDsitMatcher: initialized with knn=" << knn << ", epsilon=" << epsilon << ", searchType=" << searchType << " and maxDistField=" << maxDistField);
00114 }
00115
00116 template<typename T>
00117 MatchersImpl<T>::KDTreeVarDistMatcher::~KDTreeVarDistMatcher()
00118 {
00119
00120 }
00121
00122 template<typename T>
00123 void MatchersImpl<T>::KDTreeVarDistMatcher::init(
00124 const DataPoints& filteredReference)
00125 {
00126
00127 featureNNS.reset( NNS::create(filteredReference.features, filteredReference.features.rows() - 1, searchType, NNS::TOUCH_STATISTICS));
00128 }
00129
00130 template<typename T>
00131 typename PointMatcher<T>::Matches MatchersImpl<T>::KDTreeVarDistMatcher::findClosests(
00132 const DataPoints& filteredReading)
00133 {
00134
00135 const int pointsCount(filteredReading.features.cols());
00136 Matches matches(
00137 typename Matches::Dists(knn, pointsCount),
00138 typename Matches::Ids(knn, pointsCount)
00139 );
00140
00141 const BOOST_AUTO(maxDists, filteredReading.getDescriptorViewByName(maxDistField));
00142
00143 this->visitCounter += featureNNS->knn(filteredReading.features, matches.ids, matches.dists, maxDists.transpose(), knn, epsilon, NNS::ALLOW_SELF_MATCH);
00144
00145 return matches;
00146 }
00147
00148 template struct MatchersImpl<float>::KDTreeVarDistMatcher;
00149 template struct MatchersImpl<double>::KDTreeVarDistMatcher;