Skip to content

Commit 43e9590

Browse files
Fabien Servantservantftransperfect
authored andcommitted
Update bundle adjustment unit test for relative Landmarks
1 parent b54d80f commit 43e9590

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/aliceVision/multiview/NViewDataSet.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct NViewDatasetConfigurator
6161
double _jitter_amount;
6262

6363
NViewDatasetConfigurator(int fx = 1000, int fy = 1000, int cx = 500, int cy = 500, double distance = 1.5, double jitter_amount = 0.01);
64+
65+
bool _useRelative = false;
6466
};
6567

6668
/**

src/aliceVision/sfm/bundle/bundleAdjustment_test.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
5778
BOOST_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

Comments
 (0)