@@ -54,6 +54,27 @@ BOOST_AUTO_TEST_CASE(BUNDLE_ADJUSTMENT_EffectiveMinimization_Pinhole)
5454 BOOST_CHECK_LT (dResidual_after, dResidual_before);
5555}
5656
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+
5778BOOST_AUTO_TEST_CASE (BUNDLE_ADJUSTMENT_EffectiveMinimization_PinholeRadialK1)
5879{
5980 const int nviews = 3 ;
@@ -308,6 +329,15 @@ SfMData getInputScene(const NViewDataSet& d, const NViewDatasetConfigurator& con
308329 // Collect the image of point i in each frame.
309330 Landmark landmark;
310331 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+
311341 for (int j = 0 ; j < nviews; ++j)
312342 {
313343 Vec2 pt = d._x [j].col (i);
@@ -317,6 +347,7 @@ SfMData getInputScene(const NViewDataSet& d, const NViewDatasetConfigurator& con
317347
318348 landmark.getObservations ()[j] = Observation (pt, i, unknownScale);
319349 }
350+
320351 sfm_data.getLandmarks ()[i] = landmark;
321352 }
322353
0 commit comments