SimpleCamera.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #include <gtsam/geometry/Cal3_S2.h>
21 
22 namespace gtsam {
23 
24 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V41
25  SimpleCamera simpleCamera(const Matrix34& P) {
26 
27  // P = [A|a] = s K cRw [I|-T], with s the unknown scale
28  Matrix3 A = P.topLeftCorner(3, 3);
29  Vector3 a = P.col(3);
30 
31  // do RQ decomposition to get s*K and cRw angles
32  Matrix3 sK;
33  Vector3 xyz;
34  boost::tie(sK, xyz) = RQ(A);
35 
36  // Recover scale factor s and K
37  double s = sK(2, 2);
38  Matrix3 K = sK / s;
39 
40  // Recover cRw itself, and its inverse
41  Rot3 cRw = Rot3::RzRyRx(xyz);
42  Rot3 wRc = cRw.inverse();
43 
44  // Now, recover T from a = - s K cRw T = - A T
45  Vector3 T = -(A.inverse() * a);
46  return SimpleCamera(Pose3(wRc, T),
47  Cal3_S2(K(0, 0), K(1, 1), K(0, 1), K(0, 2), K(1, 2)));
48  }
49 #endif
50 
51 }
Eigen::Vector3d Vector3
Definition: Vector.h:43
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
static Rot3 RzRyRx(double x, double y, double z, OptionalJacobian< 3, 1 > Hx=boost::none, OptionalJacobian< 3, 1 > Hy=boost::none, OptionalJacobian< 3, 1 > Hz=boost::none)
Rotations around Z, Y, then X axes as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when looking from unchanging axis.
Definition: Rot3M.cpp:85
Array33i a
pair< Matrix3, Vector3 > RQ(const Matrix3 &A, OptionalJacobian< 3, 9 > H)
Definition: Rot3.cpp:258
RealScalar s
traits
Definition: chartTesting.h:28
A simple camera class with a Cal3_S2 calibration.
The most common 5DOF 3D->2D calibration.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:44:02