@@ -54,6 +54,27 @@ BOOST_AUTO_TEST_CASE(BUNDLE_ADJUSTMENT_EffectiveMinimization_Pinhole)
54
54
BOOST_CHECK_LT (dResidual_after, dResidual_before);
55
55
}
56
56
57
+ BOOST_AUTO_TEST_CASE (BUNDLE_ADJUSTMENT_EffectiveMinimization_Relative_Pinhole)
58
+ {
59
+ const int nviews = 3 ;
60
+ const int npoints = 6 ;
61
+ NViewDatasetConfigurator config;
62
+ config._useRelative = true ;
63
+ const NViewDataSet d = NRealisticCamerasRing (nviews, npoints, config);
64
+
65
+ // Translate the input dataset to a SfMData scene
66
+ SfMData sfmData = getInputScene (d, config, EINTRINSIC::PINHOLE_CAMERA, EDISTORTION::DISTORTION_NONE);
67
+
68
+ const double dResidual_before = RMSE (sfmData);
69
+
70
+ // Call the BA interface and let it refine (Structure and Camera parameters [Intrinsics|Motion])
71
+ std::shared_ptr<BundleAdjustment> ba_object = std::make_shared<BundleAdjustmentCeres>();
72
+ BOOST_CHECK (ba_object->adjust (sfmData));
73
+
74
+ const double dResidual_after = RMSE (sfmData);
75
+ BOOST_CHECK_LT (dResidual_after, dResidual_before);
76
+ }
77
+
57
78
BOOST_AUTO_TEST_CASE (BUNDLE_ADJUSTMENT_EffectiveMinimization_PinholeRadialK1)
58
79
{
59
80
const int nviews = 3 ;
@@ -308,6 +329,15 @@ SfMData getInputScene(const NViewDataSet& d, const NViewDatasetConfigurator& con
308
329
// Collect the image of point i in each frame.
309
330
Landmark landmark;
310
331
landmark.X = d._X .col (i);
332
+
333
+ if (config._useRelative )
334
+ {
335
+ landmark.referenceViewIndex = nviews / 2 ;
336
+ geometry::Pose3 p = sfm_data.getAbsolutePose (landmark.referenceViewIndex ).getTransform ();
337
+ geometry::Pose3 pinv = p.inverse ();
338
+ landmark.X = pinv (landmark.X );
339
+ }
340
+
311
341
for (int j = 0 ; j < nviews; ++j)
312
342
{
313
343
Vec2 pt = d._x [j].col (i);
@@ -317,6 +347,7 @@ SfMData getInputScene(const NViewDataSet& d, const NViewDatasetConfigurator& con
317
347
318
348
landmark.getObservations ()[j] = Observation (pt, i, unknownScale);
319
349
}
350
+
320
351
sfm_data.getLandmarks ()[i] = landmark;
321
352
}
322
353
0 commit comments