MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
bundler_common.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_COMMON_HEADER
11#define SFM_BUNDLER_COMMON_HEADER
12
13#include <string>
14#include <unordered_map>
15#include <vector>
16
17#include "math/vector.h"
18#include "util/aligned_memory.h"
19#include "mve/image.h"
20#include "sfm/camera_pose.h"
21#include "sfm/correspondence.h"
22#include "sfm/feature_set.h"
23#include "sfm/sift.h"
24#include "sfm/surf.h"
25#include "sfm/defines.h"
26
29
30/* -------------------- Common Data Structures -------------------- */
31
38{
39 Viewport (void);
40
44 float radial_distortion[2];
46 float principal_point[2];
47
50
56 std::vector<int> track_ids;
58 std::unordered_map<int, int> backup_tracks;
59};
60
62typedef std::vector<Viewport> ViewportList;
63
64/* --------------- Data Structure for Feature Tracks -------------- */
65
68{
69 FeatureReference (int view_id, int feature_id);
70
73};
74
76typedef std::vector<FeatureReference> FeatureReferenceList;
77
79struct Track
80{
81 bool is_valid (void) const;
82 void invalidate (void);
83 void remove_view (int view_id);
84
88};
89
91typedef std::vector<Track> TrackList;
92
93/* Observation of a survey point in a specific view. */
95{
96 SurveyObservation (int view_id, float x, float y);
97
100};
101
103typedef std::vector<SurveyObservation> SurveyObservationList;
104
111
113typedef std::vector<SurveyPoint> SurveyPointList;
114
115/* ------------- Data Structures for Feature Matching ------------- */
116
119{
120 bool operator< (TwoViewMatching const& rhs) const;
121
125};
126
128typedef std::vector<TwoViewMatching> PairwiseMatching;
129
130/* ------------------ Input/Output for Prebundle ------------------ */
131
136void
137save_prebundle_to_file (ViewportList const& viewports,
138 PairwiseMatching const& matching, std::string const& filename);
139
143void
144load_prebundle_from_file (std::string const& filename,
145 ViewportList* viewports, PairwiseMatching* matching);
146
167void
168load_survey_from_file (std::string const& filename,
169 SurveyPointList* survey_points);
170
171/* ---------------------- Feature undistortion -------------------- */
172
174undistort_feature (math::Vec2f const& f, double const k1, double const k2,
175 float const focal_length);
176
177/* ------------------------ Implementation ------------------------ */
178
179inline
180FeatureReference::FeatureReference (int view_id, int feature_id)
181 : view_id(view_id)
182 , feature_id(feature_id)
183{
184}
185
186inline
187SurveyObservation::SurveyObservation (int view_id, float x, float y)
188 : view_id(view_id)
189 , pos(x, y)
190{
191}
192
193inline bool
195{
196 return this->view_1_id == rhs.view_1_id
197 ? this->view_2_id < rhs.view_2_id
198 : this->view_1_id < rhs.view_1_id;
199}
200
201inline
203 : focal_length(0.0f)
204{
205 std::fill(this->radial_distortion, this->radial_distortion + 2, 0.0f);
206 std::fill(this->principal_point, this->principal_point + 2, 0.5f);
207}
208
209inline bool
210Track::is_valid (void) const
211{
212 return !std::isnan(this->pos[0]);
213}
214
217
218#endif /* SFM_BUNDLER_COMMON_HEADER */
Vector class for arbitrary dimensions and types.
Definition vector.h:87
std::shared_ptr< Image< T > > Ptr
Definition image.h:42
The FeatureSet holds per-feature information for a single view, and allows to transparently compute a...
Definition feature_set.h:28
std::vector< SurveyObservation > SurveyObservationList
The list of all survey point observations inside a survey point.
void load_prebundle_from_file(std::string const &filename, ViewportList *viewports, PairwiseMatching *matching)
Loads the pre-bundle data from file, initializing viewports and matching.
std::vector< Viewport > ViewportList
The list of all viewports considered for bundling.
math::Vec2f undistort_feature(math::Vec2f const &f, double const k1, double const k2, float const focal_length)
std::vector< Track > TrackList
The list of all tracks.
std::vector< FeatureReference > FeatureReferenceList
The list of all feature references inside a track.
void save_prebundle_to_file(ViewportList const &viewports, PairwiseMatching const &matching, std::string const &filename)
Saves the pre-bundle data to file, which records all viewport and matching data necessary for increme...
std::vector< SurveyPoint > SurveyPointList
The list of all survey poins.
std::vector< TwoViewMatching > PairwiseMatching
The matching result between several pairs of views.
void load_survey_from_file(std::string const &filename, SurveyPointList *survey_points)
Loads survey points and their observations from file.
std::vector< CorrespondenceIndex > CorrespondenceIndices
A list of all matching feature pairs in two images.
#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
References a 2D feature in a specific view.
SurveyObservation(int view_id, float x, float y)
Representation of a survey point.
SurveyObservationList observations
Representation of a feature track.
bool is_valid(void) const
FeatureReferenceList features
The matching result between two views.
bool operator<(TwoViewMatching const &rhs) const
CorrespondenceIndices matches
Per-viewport information.
float radial_distortion[2]
Radial distortion parameter.
std::unordered_map< int, int > backup_tracks
Backup map from features to tracks that were removed due to errors.
CameraPose pose
Camera pose for the viewport.
std::vector< int > track_ids
Per-feature track ID, -1 if not part of a track.
mve::ByteImage::Ptr image
The actual image data for debugging purposes.
float principal_point[2]
Principal point parameter.
float focal_length
Initial focal length estimate for the image.
FeatureSet features
Per-feature information.