MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
bundler_init_pair.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef SFM_BUNDLER_INIT_PAIR_HEADER
11#define SFM_BUNDLER_INIT_PAIR_HEADER
12
13#include <vector>
14
17#include "sfm/fundamental.h"
18#include "sfm/bundler_common.h"
19#include "sfm/camera_pose.h"
20#include "sfm/defines.h"
21
24
32{
33public:
64
76
77public:
78 explicit InitialPair (Options const& options);
80 void initialize (ViewportList const& viewports, TrackList const& tracks);
82 void compute_pair (Result* result);
84 void compute_pair (int view_1_id, int view_2_id, Result* result);
85
86private:
87 struct CandidatePair
88 {
89 int view_1_id;
90 int view_2_id;
91 Correspondences2D2D matches;
92 bool operator< (CandidatePair const& other) const;
93 };
94 typedef std::vector<CandidatePair> CandidatePairs;
95
96private:
97 std::size_t compute_homography_inliers (CandidatePair const& candidate);
98 bool compute_pose (CandidatePair const& candidate,
99 CameraPose* pose1, CameraPose* pose2);
100 void compute_candidate_pairs (CandidatePairs* candidates);
101 double angle_for_pose (CandidatePair const& candidate,
102 CameraPose const& pose1, CameraPose const& pose2);
103 float score_for_pair (CandidatePair const& candidate,
104 std::size_t num_inliers, double angle);
105 void debug_output (CandidatePair const& candidate,
106 std::size_t num_inliers = 0, double angle = 0.0);
107
108private:
109 Options opts;
110 ViewportList const* viewports;
111 TrackList const* tracks;
112};
113
114/* ------------------------ Implementation ------------------------ */
115
116inline
117InitialPair::Options::Options (void)
118 : max_homography_inliers(0.6f)
119 , min_num_matches(50)
120 , min_triangulation_angle(MATH_DEG2RAD(5.0))
121 , verbose_output(false)
122{
123}
124
125inline
127 : opts(options)
128 , viewports(nullptr)
129 , tracks(nullptr)
130{
131}
132
133inline void
134InitialPair::initialize (ViewportList const& viewports, TrackList const& tracks)
135{
136 this->viewports = &viewports;
137 this->tracks = &tracks;
138}
139
140inline bool
141InitialPair::CandidatePair::operator< (CandidatePair const& other) const
142{
143 return this->matches.size() < other.matches.size();
144}
145
148
149#endif /* SFM_BUNDLER_INIT_PAIR_HEADER */
Tries to find an initial viewport pair to start the reconstruction with.
InitialPair(Options const &options)
void initialize(ViewportList const &viewports, TrackList const &tracks)
Initializes the module with viewport and track information.
#define MATH_DEG2RAD(x)
Definition defines.h:78
std::vector< Viewport > ViewportList
The list of all viewports considered for bundling.
std::vector< Track > TrackList
The list of all tracks.
std::vector< Correspondence2D2D > Correspondences2D2D
#define SFM_BUNDLER_NAMESPACE_END
Definition defines.h:17
#define SFM_BUNDLER_NAMESPACE_BEGIN
Definition defines.h:16
#define SFM_NAMESPACE_END
Definition defines.h:14
#define SFM_NAMESPACE_BEGIN
Definition defines.h:13
The camera pose is the 3x4 matrix P = K [R | t].
Definition camera_pose.h:40
bool verbose_output
Produce status messages on the console.
int min_num_matches
Minimum number of pair matches.
double min_triangulation_angle
Minimum triangulation angle of tracks (in radians).
float max_homography_inliers
The maximum percentage of homography inliers.
RansacHomography::Options homography_opts
The algorithm tries to explain the matches using a homography.
The resulting initial pair with view IDs and relative camera pose.