34 using namespace gtsam;
39 std::make_shared<Cal3_S2>(1500, 1200, 0.1, 640, 480);
63 TEST(triangulation, twoPoses) {
66 double rank_tol = 1
e-9;
70 std::optional<Point3> actual1 =
76 std::optional<Point3> actual2 =
85 std::optional<Point3> actual3 =
91 std::optional<Point3> actual4 =
96 TEST(triangulation, twoCamerasUsingLOST) {
103 double rank_tol = 1
e-9;
106 std::optional<Point3> actual1 =
117 std::optional<Point3> actual2 =
118 triangulatePoint3<PinholeCamera<Cal3_S2>>(
120 false, measurementNoise,
125 TEST(triangulation, twoCamerasLOSTvsDLT) {
140 const double rank_tol = 1
e-9;
143 std::optional<Point3> estimateLOST =
152 std::optional<Point3> estimateDLT =
161 TEST(triangulation, twoPosesCal3DS2) {
162 static const std::shared_ptr<Cal3DS2> sharedDistortedCal =
163 std::make_shared<Cal3DS2>(1500, 1200, 0, 640, 480, -.3, 0.1, 0.0001,
176 double rank_tol = 1
e-9;
180 std::optional<Point3> actual1 =
187 std::optional<Point3> actual2 =
197 std::optional<Point3> actual3 =
204 std::optional<Point3> actual4 =
213 TEST(triangulation, twoPosesFisheye) {
215 static const std::shared_ptr<Calibration> sharedDistortedCal =
216 std::make_shared<Calibration>(1500, 1200, .1, 640, 480, -.3, 0.1,
229 double rank_tol = 1
e-9;
233 std::optional<Point3> actual1 =
240 std::optional<Point3> actual2 =
250 std::optional<Point3> actual3 =
257 std::optional<Point3> actual4 =
265 TEST(triangulation, twoPosesBundler) {
266 std::shared_ptr<Cal3Bundler> bundlerCal =
267 std::make_shared<Cal3Bundler>(1500, 0.1, 0.2, 640, 480);
278 double rank_tol = 1
e-9;
280 std::optional<Point3> actual =
289 std::optional<Point3> actual2 =
296 TEST(triangulation, fourPoses) {
299 std::optional<Point3> actual =
308 std::optional<Point3> actual2 =
317 poses.push_back(
pose3);
320 std::optional<Point3> triangulated_3cameras =
325 std::optional<Point3> triangulated_3cameras_opt =
333 #ifdef GTSAM_THROW_CHEIRALITY_EXCEPTION
336 poses.push_back(pose4);
345 TEST(triangulation, threePoses_robustNoiseModel) {
355 std::optional<Point3> actual =
363 std::optional<Point3> actual2 =
370 std::optional<Point3> actual3 =
376 auto model = noiseModel::Robust::Create(
377 noiseModel::mEstimator::Huber::Create(1.345), noiseModel::Unit::Create(2));
378 std::optional<Point3> actual4 = triangulatePoint3<Cal3_S2>(
385 TEST(triangulation, fourPoses_robustNoiseModel) {
396 std::optional<Point3> actual =
408 std::optional<Point3> actual2 =
415 std::optional<Point3> actual3 =
421 auto model = noiseModel::Robust::Create(
422 noiseModel::mEstimator::Huber::Create(1.345), noiseModel::Unit::Create(2));
423 std::optional<Point3> actual4 = triangulatePoint3<Cal3_S2>(
430 TEST(triangulation, fourPoses_distinct_Ks) {
446 std::optional<Point3> actual =
455 std::optional<Point3> actual2 =
461 Cal3_S2 K3(700, 500, 0, 640, 480);
468 std::optional<Point3> triangulated_3cameras =
473 std::optional<Point3> triangulated_3cameras_opt =
482 #ifdef GTSAM_THROW_CHEIRALITY_EXCEPTION
493 TEST(triangulation, fourPoses_distinct_Ks_distortion) {
494 Cal3DS2 K1(1500, 1200, 0, 640, 480, -.3, 0.1, 0.0001, -0.0003);
499 Cal3DS2 K2(1600, 1300, 0, 650, 440, -.2, 0.05, 0.0002, -0.0001);
509 std::optional<Point3> actual =
515 TEST(triangulation, outliersAndFarLandmarks) {
531 double landmarkDistanceThreshold = 10;
533 1.0,
false, landmarkDistanceThreshold);
539 landmarkDistanceThreshold = 4;
541 1.0,
false, landmarkDistanceThreshold);
549 Cal3_S2 K3(700, 500, 0, 640, 480);
556 landmarkDistanceThreshold = 10;
557 double outlierThreshold = 100;
564 outlierThreshold = 5;
572 TEST(triangulation, twoIdenticalPoses) {
591 const vector<Pose3> poses{
Pose3()};
599 TEST(triangulation, StereoTriangulateNonlinear) {
600 auto stereoK = std::make_shared<Cal3_S2Stereo>(1733.75, 1733.75, 0, 689.645,
605 m1 << 0.796888717, 0.603404026, -0.0295271487, 46.6673779, 0.592783835,
606 -0.77156583, 0.230856632, 66.2186159, 0.116517574, -0.201470143,
607 -0.9725393, -4.28382528, 0, 0, 0, 1;
609 m2 << -0.955959025, -0.29288915, -0.0189328569, 45.7169799, -0.29277519,
610 0.947083213, 0.131587097, 65.843136, -0.0206094928, 0.131334858,
611 -0.991123524, -4.3525033, 0, 0, 0, 1;
621 Point3(46.0536958, 66.4621179, -6.56285929);
646 const SharedDiagonal posePrior = noiseModel::Isotropic::Sigma(6, 1
e-9);
703 TEST(triangulation, twoPoses_sphericalCamera) {
717 double rank_tol = 1
e-9;
730 std::optional<Point3> actual1 =
737 std::optional<Point3> actual2 =
748 std::optional<Point3> actual3 =
755 std::optional<Point3> actual4 =
762 TEST(triangulation, twoPoses_sphericalCamera_extremeFOV) {
765 Rot3::Ypr(-
M_PI / 2, 0., -
M_PI / 2),
788 double rank_tol = 1
e-9;
793 #ifdef GTSAM_THROW_CHEIRALITY_EXCEPTION
797 #else // otherwise project should not throw the exception
798 std::optional<Point3> actual1 =
807 #ifdef GTSAM_THROW_CHEIRALITY_EXCEPTION
811 #else // otherwise project should not throw the exception
812 std::optional<Point3> actual1 =
821 TEST(triangulation, reprojectionError_cameraComparison) {
823 Rot3::Ypr(-
M_PI / 2, 0., -
M_PI / 2),
825 Point3 landmarkL(5.0, 0.0, 0.0);
838 Unit3(measured_px_calibrated[0], measured_px_calibrated[1], 1.0);
839 Unit3 expected_measured_u =
845 Vector2 expectedErrorPinhole =
Vector2(-px_noise[0], -px_noise[1]);
852 Vector2 expectedErrorSpherical(-0.00360842, 0.00180419);