MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
triangulate.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_TRIANGULATE_HEADER
11#define SFM_TRIANGULATE_HEADER
12
13#include <vector>
14#include <ostream>
15
16#include "math/vector.h"
17#include "sfm/correspondence.h"
18#include "sfm/camera_pose.h"
19#include "sfm/defines.h"
20
22
23/* ---------------- Low-level triangulation solver ---------------- */
24
30triangulate_match (Correspondence2D2D const& match,
31 CameraPose const& pose1, CameraPose const& pose2);
32
38triangulate_track (std::vector<math::Vec2f> const& pos,
39 std::vector<CameraPose const*> const& poses);
40
45bool
46is_consistent_pose (Correspondence2D2D const& match,
47 CameraPose const& pose1, CameraPose const& pose2);
48
49/* --------------- Higher-level triangulation class --------------- */
50
59{
60public:
61 struct Options
62 {
63 Options (void);
64
71 };
72
86
87public:
88 explicit Triangulate (Options const& options);
89 bool triangulate (std::vector<CameraPose const*> const& poses,
90 std::vector<math::Vec2f> const& positions,
91 math::Vec3d* track_pos, Statistics* stats = nullptr,
92 std::vector<std::size_t>* outliers = nullptr) const;
93 void print_statistics (Statistics const& stats, std::ostream& out) const;
94
95private:
96 Options const opts;
97 double const cos_angle_thres;
98};
99
100/* ------------------------ Implementation ------------------------ */
101
102inline
103Triangulate::Options::Options (void)
104 : error_threshold(0.01)
105 , angle_threshold(MATH_DEG2RAD(1.0))
106 , min_num_views(2)
107{
108}
109
110inline
112 : num_new_tracks(0)
113 , num_large_error(0)
114 , num_behind_camera(0)
115 , num_too_small_angle(0)
116{
117}
118
119inline
121 : opts(options)
122 , cos_angle_thres(std::cos(options.angle_threshold))
123{
124}
125
127
128#endif // SFM_TRIANGULATE_HEADER
Vector class for arbitrary dimensions and types.
Definition vector.h:87
Triangulation routine that triangulates a track from camera poses and 2D image positions while keepin...
Definition triangulate.h:59
Triangulate(Options const &options)
#define MATH_DEG2RAD(x)
Definition defines.h:78
math::Vector< double, 3 > triangulate_match(Correspondence2D2D const &match, CameraPose const &pose1, CameraPose const &pose2)
Given an image correspondence in two views and the corresponding poses, this function triangulates th...
math::Vector< double, 3 > triangulate_track(std::vector< math::Vec2f > const &pos, std::vector< CameraPose const * > const &poses)
Given any number of 2D image positions and the corresponding camera poses, this function triangulates...
bool is_consistent_pose(Correspondence2D2D const &match, CameraPose const &pose1, CameraPose const &pose2)
Given a two-view pose configuration and a correspondence, this function returns true if the triangula...
STL namespace.
#define SFM_NAMESPACE_END
Definition defines.h:14
#define SFM_NAMESPACE_BEGIN
Definition defines.h:13
double angle_threshold
Threshold on the triangulation angle (in radians).
Definition triangulate.h:68
double error_threshold
Threshold on reprojection error for outlier detection.
Definition triangulate.h:66
int min_num_views
Minimal number of views with small error (inliers).
Definition triangulate.h:70
int num_behind_camera
Number of tracks that appeared behind the camera.
Definition triangulate.h:82
int num_large_error
Number of tracks with too large reprojection error.
Definition triangulate.h:80
int num_too_small_angle
Number of tracks with too small triangulation angle.
Definition triangulate.h:84
int num_new_tracks
The number of successfully triangulated tracks.
Definition triangulate.h:78