32 size_t m = projection_matrices.size();
35 Matrix A = Matrix::Zero(m * 2, 4);
37 for (
size_t i = 0;
i <
m;
i++) {
39 const Matrix34&
projection = projection_matrices.at(
i);
40 const Point2&
p = measurements.at(
i);
48 A.row(row) = p.x() * projection.row(2) - projection.row(0);
49 A.row(row + 1) = p.y() * projection.row(2) - projection.row(1);
51 const auto [rank,
error,
v] =
DLT(A, rank_tol);
61 const std::vector<Unit3>& measurements,
double rank_tol) {
63 size_t m = projection_matrices.size();
66 Matrix A = Matrix::Zero(m * 2, 4);
68 for (
size_t i = 0;
i <
m;
i++) {
70 const Matrix34&
projection = projection_matrices.at(
i);
76 A.row(row) = p.x() * projection.row(2) - p.z() * projection.row(0);
77 A.row(row + 1) = p.y() * projection.row(2) - p.z() * projection.row(1);
79 const auto [rank,
error,
v] =
DLT(A, rank_tol);
90 size_t m = calibratedMeasurements.size();
91 assert(m == poses.size());
94 Matrix A = Matrix::Zero(m * 2, 3);
95 Matrix b = Matrix::Zero(m * 2, 1);
97 for (
size_t i = 0;
i <
m;
i++) {
98 const Pose3& wTi = poses[
i];
101 const Pose3& wTj = poses[
j];
106 double num_i = wZi.cross(wZj).norm();
107 double den_i = d_ij.cross(wZj).norm();
112 if (num_i == 0 || den_i == 0) {
113 bool success =
false;
114 for (
size_t k = 2; k <
m; k++) {
116 const Pose3& wTj = poses[
j];
120 num_i = wZi.cross(wZj).norm();
121 den_i = d_ij.cross(wZj).norm();
122 if (num_i > 0 && den_i > 0) {
131 const double q_i = num_i / (measurementNoise->sigma() * den_i);
133 const Matrix23 coefficientMat =
134 q_i *
skewSymmetric(calibratedMeasurements[i]).topLeftCorner(2, 3) *
137 A.block<2, 3>(2 *
i, 0) << coefficientMat;
138 b.block<2, 1>(2 *
i, 0) << coefficientMat * wTi.
translation();
146 return A_Qr.
solve(b);
156 return Point3(v.head<3>() / v[3]);
162 const std::vector<Unit3>& measurements,
double rank_tol) {
167 return Point3(v.head<3>() / v[3]);
194 return result.
at<
Point3>(landmarkKey);
std::vector< Point3, Eigen::aligned_allocator< Point3 > > Point3Vector
const Solve< ColPivHouseholderQR< _MatrixType >, Rhs > solve(const MatrixBase< Rhs > &b) const
const MATRIX::ConstRowXpr row(const MATRIX &A, size_t j)
const Point3 & translation(OptionalJacobian< 3, 6 > Hself={}) const
get translation
virtual const Values & optimize()
const ValueType at(Key j) const
double lambdaFactor
The amount by which to multiply or divide lambda when adjusting lambda (default: 10.0)
std::tuple< int, double, Vector > DLT(const Matrix &A, double rank_tol)
Verbosity verbosity
The printing verbosity during optimization (default SILENT)
noiseModel::Isotropic::shared_ptr SharedIsotropic
NonlinearFactorGraph graph
double absoluteErrorTol
The maximum absolute error decrease to stop iterating (default 1e-5)
static const SmartProjectionParams params
Base class for all pinhole cameras.
Point3 triangulateLOST(const std::vector< Pose3 > &poses, const Point3Vector &calibratedMeasurements, const SharedIsotropic &measurementNoise, double rank_tol)
Triangulation using the LOST (Linear Optimal Sine Triangulation) algorithm proposed in https://arxiv...
STL compatible allocator to use with types requiring a non standrad alignment.
Point3 triangulateDLT(const std::vector< Matrix34, Eigen::aligned_allocator< Matrix34 >> &projection_matrices, const Point2Vector &measurements, double rank_tol)
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
Functions for triangulation.
Array< int, Dynamic, 1 > v
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
Exception thrown by triangulateDLT when SVD returns rank < 3.
ColPivHouseholderQR & setThreshold(const RealScalar &threshold)
Matrix3 skewSymmetric(double wx, double wy, double wz)
Expression< Point2 > projection(f, p_cam)
std::vector< Point2, Eigen::aligned_allocator< Point2 > > Point2Vector
Vector4 triangulateHomogeneousDLT(const std::vector< Matrix34, Eigen::aligned_allocator< Matrix34 >> &projection_matrices, const Point2Vector &measurements, double rank_tol)
const Rot3 & rotation(OptionalJacobian< 3, 6 > Hself={}) const
get rotation
Point3 rotate(const Point3 &p, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
VerbosityLM verbosityLM
The verbosity level for Levenberg-Marquardt (default: SILENT), see also NonlinearOptimizerParams::ver...
std::uint64_t Key
Integer nonlinear key type.
LinearSolverType linearSolverType
The type of linear solver to use in the nonlinear optimizer.
size_t maxIterations
The maximum iterations to stop iterating (default 100)
double lambdaInitial
The initial Levenberg-Marquardt damping term (default: 1e-5)