Skip to content

Commit

Permalink
[geodesy] Add a geodesy module to OpenMVG openMVG#547
Browse files Browse the repository at this point in the history
- fix test for clang (and other compiler) in case view_id and pose_id are not in increasing order
  • Loading branch information
pmoulon committed Dec 27, 2016
1 parent b6d6067 commit bcb9d26
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/openMVG/sfm/sfm_data_BA_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,12 @@ TEST(BUNDLE_ADJUSTMENT, EffectiveMinimization_Pinhole_GCP)
EXPECT_TRUE( dResidual_before > dResidual_after);

//-- Check camera pose are to the right place (since GCP was used, the camera coordinates must be the same)
size_t cpt = 0;
for (const auto & view_it : sfm_data.GetViews())
{
const Pose3 pose = sfm_data.GetPoseOrDie(view_it.second.get());
const double position_residual = (d._C[cpt] - pose.center()).norm();
const View * view = view_it.second.get();
const Pose3 pose = sfm_data.GetPoseOrDie(view);
const double position_residual = (d._C[view->id_pose] - pose.center()).norm();
EXPECT_NEAR(0.0, position_residual, 1e-4);
++cpt;
}
}

Expand Down Expand Up @@ -236,14 +235,13 @@ TEST(BUNDLE_ADJUSTMENT, EffectiveMinimization_Pinhole_PosePriors) {

// Compute distance between SfM poses center and GPS Priors
Mat residuals(3, sfm_data.GetViews().size());
size_t cpt = 0;
for (const auto & view_it : sfm_data.GetViews())
{
const ViewPriors * view = dynamic_cast<ViewPriors*>(view_it.second.get());
residuals.col(cpt++) = (sfm_data.GetPoseOrDie(view).center() - view->pose_center_).transpose();
residuals.col(view->id_pose) = (sfm_data.GetPoseOrDie(view).center() - view->pose_center_).transpose();
}
// Check that the scene is not at the position of the POSE PRIORS center.
EXPECT_FALSE(residuals.colwise().norm().sum() < 1e-8);
EXPECT_FALSE( (residuals.colwise().norm().sum() < 1e-8) );
}

// Then activate BA with pose prior & check that the scene is at the right place
Expand All @@ -263,13 +261,12 @@ TEST(BUNDLE_ADJUSTMENT, EffectiveMinimization_Pinhole_PosePriors) {
EXPECT_TRUE( dResidual_before > dResidual_after);

// Compute distance between SfM poses center and GPS Priors
size_t cpt = 0;
for (const auto & view_it : sfm_data.GetViews())
{
const Pose3 pose = sfm_data.GetPoseOrDie(view_it.second.get());
const double position_residual = (d._C[cpt] - pose.center()).norm();
const ViewPriors * view = dynamic_cast<ViewPriors*>(view_it.second.get());
const Pose3 pose = sfm_data.GetPoseOrDie(view);
const double position_residual = (d._C[view->id_pose] - pose.center()).norm();
EXPECT_NEAR(0.0, position_residual, 1e-8);
++cpt;
}
}
}
Expand Down

0 comments on commit bcb9d26

Please sign in to comment.