ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
generalized_relative_pose.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <vector>
12 
13 #include "util/alignment.h"
14 #include "util/types.h"
15 
16 namespace colmap {
17 
18 // Solver for the Generalized Relative Pose problem using a minimal of 8 2D-2D
19 // correspondences. This implementation is based on:
20 //
21 // "Efficient Computation of Relative Pose for Multi-Camera Systems",
22 // Kneip and Li. CVPR 2014.
23 //
24 // Note that the solution to this problem is degenerate in the case of pure
25 // translation and when all correspondences are observed from the same cameras.
26 //
27 // The implementation is a modified and improved version of Kneip's original
28 // implementation in OpenGV licensed under the BSD license.
30 public:
31  // The generalized image observations of the left camera, which is composed
32  // of the relative pose of the specific camera in the generalized camera and
33  // its image observation.
34  struct X_t {
35  // The relative transformation from the generalized camera to the camera
36  // frame of the observation.
38  // The 2D image feature observation.
39  Eigen::Vector2d xy;
40  };
41 
42  // The normalized image feature points in the left camera.
43  typedef X_t Y_t;
44  // The relative transformation between the two generalized cameras.
46 
47  // The minimum number of samples needed to estimate a model. Note that in
48  // theory the minimum required number of samples is 6 but Laurent Kneip
49  // showed in his paper that using 8 samples is more stable.
50  static const int kMinNumSamples = 8;
51 
52  // Estimate the most probable solution of the GR6P problem from a set of
53  // six 2D-2D point correspondences.
54  static std::vector<M_t> Estimate(const std::vector<X_t>& points1,
55  const std::vector<Y_t>& points2);
56 
57  // Calculate the squared Sampson error between corresponding points.
58  static void Residuals(const std::vector<X_t>& points1,
59  const std::vector<Y_t>& points2,
60  const M_t& proj_matrix,
61  std::vector<double>* residuals);
62 };
63 
64 } // namespace colmap
65 
66 // EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION_CUSTOM(colmap::GR6PEstimator::X_t)
colmap::GR6PEstimator::X_t::rel_tform
Eigen::Matrix3x4d rel_tform
Definition: generalized_relative_pose.h:37
types.h
Eigen::Matrix3x4d
Matrix< double, 3, 4 > Matrix3x4d
Definition: types.h:39
colmap::ComposeProjectionMatrix
Eigen::Matrix3x4d ComposeProjectionMatrix(const Eigen::Vector4d &qvec, const Eigen::Vector3d &tvec)
Definition: projection.cc:39
colmap::SetPRNGSeed
void SetPRNGSeed(unsigned seed)
Definition: random.cc:40
alignment.h
triangulation.h
generalized_relative_pose.h
Eigen::Vector6d
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Eigen.h:107
colmap::EssentialMatrixFromPose
Eigen::Matrix3d EssentialMatrixFromPose(const Eigen::Matrix3d &R, const Eigen::Vector3d &t)
Definition: essential_matrix.cc:90
colmap::RANSAC::estimator
Estimator estimator
Definition: ransac.h:107
generalized_absolute_pose.h
colmap::RANSACOptions
Definition: ransac.h:22
colmap::GR6PEstimator::Y_t
X_t Y_t
Definition: generalized_relative_pose.h:43
testing.h
colmap::GR6PEstimator::X_t::xy
Eigen::Vector2d xy
Definition: generalized_relative_pose.h:39
projection.h
colmap::GR6PEstimator::Estimate
static std::vector< M_t > Estimate(const std::vector< X_t > &points1, const std::vector< Y_t > &points2)
Definition: generalized_relative_pose.cc:396
colmap::GR6PEstimator::X_t
Definition: generalized_relative_pose.h:34
colmap::InvertProjectionMatrix
Eigen::Matrix3x4d InvertProjectionMatrix(const Eigen::Matrix3x4d &proj_matrix)
Definition: projection.cc:55
y
normal_z y
Definition: my_point_types.h:168
random.h
essential_matrix.h
colmap::GP3PEstimator::Residuals
void Residuals(const std::vector< X_t > &points2D, const std::vector< Y_t > &points3D, const M_t &proj_matrix, std::vector< double > *residuals)
Definition: generalized_absolute_pose.cc:267
e
const double * e
Definition: essential_matrix_poly.h:10
colmap::RANSAC::Estimate
Report Estimate(const std::vector< typename Estimator::X_t > &X, const std::vector< typename Estimator::Y_t > &Y)
Definition: ransac.h:159
colmap::GR6PEstimator::M_t
Eigen::Matrix3x4d M_t
Definition: generalized_relative_pose.h:45
colmap::RANSACOptions::max_error
double max_error
Definition: ransac.h:25
colmap::GR6PEstimator::kMinNumSamples
static const int kMinNumSamples
Definition: generalized_relative_pose.h:50
colmap::ComputeRelativePose
void ComputeRelativePose(const Eigen::Vector4d &qvec1, const Eigen::Vector3d &tvec1, const Eigen::Vector4d &qvec2, const Eigen::Vector3d &tvec2, Eigen::Vector4d *qvec12, Eigen::Vector3d *tvec12)
Definition: pose.cc:173
colmap::SimilarityTransform3
Definition: similarity_transform.h:24
pose.h
logging.h
colmap::GR6PEstimator::Residuals
static void Residuals(const std::vector< X_t > &points1, const std::vector< Y_t > &points2, const M_t &proj_matrix, std::vector< double > *residuals)
Definition: generalized_relative_pose.cc:588
colmap::RANSAC
Definition: ransac.h:56
colmap
Definition: AutomaticReconstructionController.h:17
rotation
Eigen::Matrix3d rotation
Definition: VoxelGridIO.cpp:27
similarity_transform.h
colmap::GR6PEstimator
Definition: generalized_relative_pose.h:29
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(Estimate)
Definition: generalized_absolute_pose_test.cc:48
t12
Eigen::Vector2f t12
Definition: vote_and_verify.cc:67
ransac.h