Berkeley SfM
naive_matcher_2d3d.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: David Fridovich-Keil ( dfk@eecs.berkeley.edu )
35  * Erik Nelson ( eanelson@eecs.berkeley.edu )
36  */
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 //
40 // This class provides a naive O(n^2) descriptor matcher for matching 2d
41 // Features to 3D Landmarks. Right now, this class does not inherit from
42 // FeatureMatcher because that class assumes we are matching Features between
43 // two or more images, and here we are not doing that precisely.
44 //
45 ///////////////////////////////////////////////////////////////////////////////
46 
47 #ifndef BSFM_MATCHING_NAIVE_MATCHER_2D3D_H
48 #define BSFM_MATCHING_NAIVE_MATCHER_2D3D_H
49 
50 #include <algorithm>
51 #include <memory>
52 #include <vector>
53 
54 #include "distance_metric.h"
55 #include "feature.h"
56 #include "feature_match.h"
58 
59 #include "../sfm/view.h"
60 #include "../slam/landmark.h"
61 #include "../slam/observation.h"
62 #include "../util/disallow_copy_and_assign.h"
63 
64 namespace bsfm {
65 
67  public:
70 
71  // Match observations stored in the view referred to by 'view_index' with
72  // landmarks in 'landmark_indices'. Update all matched observations in the
73  // view.
74  bool Match(const FeatureMatcherOptions& options,
75  const ViewIndex& view_index,
76  const std::vector<LandmarkIndex>& landmark_indices);
77 
78  private:
80 
81  // Compute one-way matches.
82  // Note: this is essentially the function
83  // NaiveFeatureMatcher::ComputePutativeMatches but it has been adjusted
84  // slightly for this 2d-3d matcher.
85  void ComputeOneWayMatches(const std::vector<Descriptor>& descriptors1,
86  const std::vector<Descriptor>& descriptors2,
87  std::vector<LightFeatureMatch>& matches);
88 
89  // Compute symmetric matches.
90  // Note: this is essentially the function FeatureMatcher::SymmetricMatches
91  // but it has been adjusted slightly for this 2d-3d matcher.
93  const std::vector<LightFeatureMatch>& feature_matches_lhs,
94  std::vector<LightFeatureMatch>& feature_matches_rhs);
95 
96  // Feature matching options.
98 
99 }; //\class NaiveMatcher2D3D
100 
101 } //\namespace bsfm
102 
103 #endif
unsigned int ViewIndex
Definition: types.h:58
bool Match(const FeatureMatcherOptions &options, const ViewIndex &view_index, const std::vector< LandmarkIndex > &landmark_indices)
void ComputeSymmetricMatches(const std::vector< LightFeatureMatch > &feature_matches_lhs, std::vector< LightFeatureMatch > &feature_matches_rhs)
Definition: camera.cpp:50
void ComputeOneWayMatches(const std::vector< Descriptor > &descriptors1, const std::vector< Descriptor > &descriptors2, std::vector< LightFeatureMatch > &matches)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
FeatureMatcherOptions options_