Cal3_S2Stereo.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 
19 
20 #include <iostream>
21 
22 namespace gtsam {
23 
24 /* ************************************************************************* */
25 std::ostream& operator<<(std::ostream& os, const Cal3_S2Stereo& cal) {
26  os << (Cal3_S2&)cal;
27  os << ", b: " << cal.baseline();
28  return os;
29 }
30 
31 /* ************************************************************************* */
32 void Cal3_S2Stereo::print(const std::string& s) const {
33  std::cout << s << (s != "" ? " " : "");
34  std::cout << "K: " << (Matrix)K() << std::endl;
35  std::cout << "Baseline: " << b_ << std::endl;
36 }
37 
38 /* ************************************************************************* */
39 bool Cal3_S2Stereo::equals(const Cal3_S2Stereo& other, double tol) const {
40  const Cal3_S2* base = dynamic_cast<const Cal3_S2*>(&other);
41  return (Cal3_S2::equals(*base, tol) &&
42  std::fabs(b_ - other.baseline()) < tol);
43 }
44 
45 /* ************************************************************************* */
47  OptionalJacobian<2, 2> Dp) const {
48  const double x = p.x(), y = p.y();
49  if (Dcal) *Dcal << x, 0.0, y, 1.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 1.0, 0.0;
50  if (Dp) *Dp << fx_, s_, 0.0, fy_;
51  return Point2(fx_ * x + s_ * y + u0_, fy_ * y + v0_);
52 }
53 
54 /* ************************************************************************* */
56  OptionalJacobian<2, 2> Dp) const {
57  const double u = p.x(), v = p.y();
58  double delta_u = u - u0_, delta_v = v - v0_;
59  double inv_fx = 1 / fx_, inv_fy = 1 / fy_;
60  double inv_fy_delta_v = inv_fy * delta_v;
61  double inv_fx_s_inv_fy = inv_fx * s_ * inv_fy;
62 
63  Point2 point(inv_fx * (delta_u - s_ * inv_fy_delta_v), inv_fy_delta_v);
64  if (Dcal) {
65  *Dcal << -inv_fx * point.x(), inv_fx * s_ * inv_fy * inv_fy_delta_v,
66  -inv_fx * point.y(), -inv_fx, inv_fx_s_inv_fy, 0, 0,
67  -inv_fy * point.y(), 0, 0, -inv_fy, 0;
68  }
69  if (Dp) *Dp << inv_fx, -inv_fx_s_inv_fy, 0, inv_fy;
70  return point;
71 }
72 
73 /* ************************************************************************* */
74 
75 } // namespace gtsam
gtsam::Cal3::fx_
double fx_
Definition: Cal3.h:71
base
Annotation indicating that a class derives from another given type.
Definition: attr.h:64
s
RealScalar s
Definition: level1_cplx_impl.h:126
gtsam::Cal3_S2Stereo::calibrate
Point2 calibrate(const Point2 &p, OptionalJacobian< 2, 6 > Dcal={}, OptionalJacobian< 2, 2 > Dp={}) const
Definition: Cal3_S2Stereo.cpp:55
gtsam::operator<<
std::ostream & operator<<(std::ostream &os, const Dih6 &m)
Definition: testGroup.cpp:109
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
gtsam::Cal3_S2Stereo::b_
double b_
Stereo baseline.
Definition: Cal3_S2Stereo.h:32
gtsam::Cal3_S2::equals
bool equals(const Cal3_S2 &K, double tol=10e-9) const
Check if equal up to specified tolerance.
Definition: Cal3_S2.cpp:39
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
os
ofstream os("timeSchurFactors.csv")
gtsam::Cal3::u0_
double u0_
Definition: Cal3.h:73
fixture::cal
const Cal3_S2 cal(focalLength, focalLength, 0.0, principalPoint.x(), principalPoint.y())
boost::multiprecision::fabs
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:119
gtsam::Cal3_S2Stereo::K
Matrix3 K() const override
return calibration matrix K, same for left and right
Definition: Cal3_S2Stereo.h:108
gtsam_unstable.tests.test_ProjectionFactorRollingShutter.point
point
Definition: test_ProjectionFactorRollingShutter.py:25
gtsam::Cal3_S2Stereo::uncalibrate
Point2 uncalibrate(const Point2 &p, OptionalJacobian< 2, 6 > Dcal={}, OptionalJacobian< 2, 2 > Dp={}) const
Definition: Cal3_S2Stereo.cpp:46
gtsam::Cal3::fy_
double fy_
focal length
Definition: Cal3.h:71
gtsam::Point2
Vector2 Point2
Definition: Point2.h:32
Cal3_S2Stereo.h
The most common 5DOF 3D->2D calibration + Stereo baseline.
y
Scalar * y
Definition: level1_cplx_impl.h:124
gtsam
traits
Definition: SFMdata.h:40
gtsam::Cal3_S2Stereo::print
void print(const std::string &s="") const override
print with optional string
Definition: Cal3_S2Stereo.cpp:32
gtsam::Cal3_S2Stereo
The most common 5DOF 3D->2D calibration, stereo version.
Definition: Cal3_S2Stereo.h:30
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
p
float * p
Definition: Tutorial_Map_using.cpp:9
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::Cal3_S2Stereo::equals
bool equals(const Cal3_S2Stereo &other, double tol=10e-9) const
Check if equal up to specified tolerance.
Definition: Cal3_S2Stereo.cpp:39
gtsam::Cal3_S2
The most common 5DOF 3D->2D calibration.
Definition: Cal3_S2.h:34
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Cal3::s_
double s_
skew
Definition: Cal3.h:72
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::Cal3::v0_
double v0_
principal point
Definition: Cal3.h:73


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:56