ProjectionFactorRollingShutter.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 namespace gtsam {
21 
23  const Pose3& pose_a, const Pose3& pose_b, const Point3& point,
25  OptionalMatrixType H3) const {
26  try {
27  Pose3 pose = interpolate<Pose3>(pose_a, pose_b, alpha_, H1, H2);
28  gtsam::Matrix Hprj;
29  if (body_P_sensor_) {
30  if (H1 || H2 || H3) {
31  gtsam::Matrix HbodySensor;
33  pose.compose(*body_P_sensor_, HbodySensor), *K_);
34  Point2 reprojectionError(camera.project(point, Hprj, H3, {}) -
35  measured_);
36  if (H1) *H1 = Hprj * HbodySensor * (*H1);
37  if (H2) *H2 = Hprj * HbodySensor * (*H2);
38  return reprojectionError;
39  } else {
41  return camera.project(point) - measured_;
42  }
43  } else {
45  Point2 reprojectionError(camera.project(point, Hprj, H3, {}) -
46  measured_);
47  if (H1) *H1 = Hprj * (*H1);
48  if (H2) *H2 = Hprj * (*H2);
49  return reprojectionError;
50  }
51  } catch (CheiralityException& e) {
52  if (H1) *H1 = Matrix::Zero(2, 6);
53  if (H2) *H2 = Matrix::Zero(2, 6);
54  if (H3) *H3 = Matrix::Zero(2, 3);
56  std::cout << e.what() << ": Landmark "
57  << DefaultKeyFormatter(this->key<2>()) << " moved behind camera "
58  << DefaultKeyFormatter(this->key<1>()) << std::endl;
59  if (throwCheirality_) throw CheiralityException(this->key<2>());
60  }
61  return Vector2::Constant(2.0 * K_->fx());
62 }
63 
64 } // namespace gtsam
Vector2 Point2
Definition: Point2.h:32
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
Basic projection factor for rolling shutter cameras.
Point2 project(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 3 > Dpoint={}, OptionalJacobian< 2, DimK > Dcal={}) const
project a 3D point from world coordinates into the image
Definition: PinholePose.h:112
Matrix * OptionalMatrixType
Eigen::VectorXd Vector
Definition: Vector.h:38
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Class compose(const Class &g) const
Definition: Lie.h:48
traits
Definition: chartTesting.h:28
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
std::optional< Pose3 > body_P_sensor_
The pose of the sensor in the body frame.
Vector evaluateError(const Pose3 &pose_a, const Pose3 &pose_b, const Point3 &point, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
Evaluate error h(x)-z and optionally derivatives.
Vector3 Point3
Definition: Point3.h:38
static const CalibratedCamera camera(kDefaultPose)
std::shared_ptr< Cal3_S2 > K_
shared pointer to calibration object
const char * what() const noexcept override


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:26