PICCANTE  0.4
The hottest HDR imaging library!
feature_matcher.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_FEATURES_MATCHING_FEATURE_MATCHER
19 #define PIC_FEATURES_MATCHING_FEATURE_MATCHER
20 
21 #include <vector>
22 
23 #ifndef PIC_DISABLE_EIGEN
24 
25 #ifndef PIC_EIGEN_NOT_BUNDLED
26  #include "../externals/Eigen/Dense"
27 #else
28  #include <Eigen/Dense>
29 #endif
30 
31 #endif
32 
33 namespace pic{
34 
38 template<class T>
40 {
41 protected:
42  std::vector<T *> *descs;
44 
45 public:
46 
52  FeatureMatcher(std::vector<T *> *descs, T desc_size)
53  {
55  }
56 
62  void update(std::vector<T *> *descs, T desc_size)
63  {
64  this->desc_size = desc_size;
65  this->descs = descs;
66  }
67 
75  virtual bool getMatch(T *desc, int &matched_j, T &dist_1)
76  {
77  return false;
78  }
79 
80 #ifndef PIC_DISABLE_EIGEN
81  void getAllMatches(std::vector<unsigned int *> &descs0, std::vector< Eigen::Vector3i > &matches)
82  {
83  matches.clear();
84 
85  for(unsigned int i = 0; i< descs0.size(); i++) {
86  int matched_j;
87  T dist_1;
88 
89  if(getMatch(descs0.at(i), matched_j, dist_1)) {
90  matches.push_back(Eigen::Vector3i(i, matched_j, dist_1));
91  }
92  }
93  }
94 
103  static void filterMatches( std::vector< Eigen::Vector2f > &c0,
104  std::vector< Eigen::Vector2f > &c1,
105  std::vector< Eigen::Vector3i > &matches,
106  std::vector< Eigen::Vector2f > &p0,
107  std::vector< Eigen::Vector2f > &p1)
108  {
109  p0.clear();
110  p1.clear();
111 
112  for(size_t i = 0; i < matches.size(); i++) {
113  int I0 = matches[i][0];
114  int I1 = matches[i][1];
115 
116  Eigen::Vector2f x = c0.at(I0);
117  Eigen::Vector2f y = c1.at(I1);
118 
119  p0.push_back(x);
120  p1.push_back(y);
121 
122  #ifdef PIC_DEBUG
123  printf("I1: %d (%d %d) -- I2: %d (%d %d) -- Score: %d\n",
124  I0, int(x[0]), int(x[1]), I1, int(y[0]), int(y[1]), matches[i][2]);
125  #endif
126  }
127  }
128 
129 #endif
130 };
131 
132 }
133 
134 #endif // PIC_FEATURES_MATCHING_FEATURE_MATCHER
The FeatureMatcher class.
Definition: feature_matcher.hpp:39
std::vector< T * > * descs
Definition: feature_matcher.hpp:42
virtual bool getMatch(T *desc, int &matched_j, T &dist_1)
getMatch
Definition: feature_matcher.hpp:75
void getAllMatches(std::vector< unsigned int *> &descs0, std::vector< Eigen::Vector3i > &matches)
Definition: feature_matcher.hpp:81
static void filterMatches(std::vector< Eigen::Vector2f > &c0, std::vector< Eigen::Vector2f > &c1, std::vector< Eigen::Vector3i > &matches, std::vector< Eigen::Vector2f > &p0, std::vector< Eigen::Vector2f > &p1)
filterMatches
Definition: feature_matcher.hpp:103
Definition: bilateral_separation.hpp:25
T desc_size
Definition: feature_matcher.hpp:43
void update(std::vector< T *> *descs, T desc_size)
update
Definition: feature_matcher.hpp:62
FeatureMatcher(std::vector< T *> *descs, T desc_size)
FeatureMatcher.
Definition: feature_matcher.hpp:52