Skip to content

Commit 63cab1b

Browse files
authored
Merge pull request #3243 from vrabaud:3.4_ceres
* Use ceres::Manifolds instead of ceres::LocalParameterization. The latter is deprecated. * Fix typo. * Fix version check. * And more version fixes.
1 parent 8864b30 commit 63cab1b

File tree

1 file changed

+22
-0
lines changed
  • modules/sfm/src/libmv_light/libmv/simple_pipeline

1 file changed

+22
-0
lines changed

modules/sfm/src/libmv_light/libmv/simple_pipeline/bundle.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "ceres/ceres.h"
2626
#include "ceres/rotation.h"
27+
#include "ceres/version.h"
2728
#include "libmv/base/vector.h"
2829
#include "libmv/logging/logging.h"
2930
#include "libmv/multiview/fundamental.h"
@@ -485,7 +486,11 @@ void EuclideanBundleCommonIntrinsics(
485486
PackCamerasRotationAndTranslation(tracks, *reconstruction);
486487

487488
// Parameterization used to restrict camera motion for modal solvers.
489+
#if CERES_VERSION_MAJOR >= 3 || (CERES_VERSION_MAJOR >= 2 && CERES_VERSION_MINOR >= 1)
490+
ceres::SubsetManifold *constant_translation_manifold = NULL;
491+
#else
488492
ceres::SubsetParameterization *constant_translation_parameterization = NULL;
493+
#endif
489494
if (bundle_constraints & BUNDLE_NO_TRANSLATION) {
490495
std::vector<int> constant_translation;
491496

@@ -494,8 +499,13 @@ void EuclideanBundleCommonIntrinsics(
494499
constant_translation.push_back(4);
495500
constant_translation.push_back(5);
496501

502+
#if CERES_VERSION_MAJOR >= 3 || (CERES_VERSION_MAJOR >= 2 && CERES_VERSION_MINOR >= 1)
503+
constant_translation_manifold =
504+
new ceres::SubsetManifold(6, constant_translation);
505+
#else
497506
constant_translation_parameterization =
498507
new ceres::SubsetParameterization(6, constant_translation);
508+
#endif
499509
}
500510

501511
// Add residual blocks to the problem.
@@ -538,8 +548,13 @@ void EuclideanBundleCommonIntrinsics(
538548
}
539549

540550
if (bundle_constraints & BUNDLE_NO_TRANSLATION) {
551+
#if CERES_VERSION_MAJOR >= 3 || (CERES_VERSION_MAJOR >= 2 && CERES_VERSION_MINOR >= 1)
552+
problem.SetParameterization(current_camera_R_t,
553+
constant_translation_manifold);
554+
#else
541555
problem.SetParameterization(current_camera_R_t,
542556
constant_translation_parameterization);
557+
#endif
543558
}
544559

545560
zero_weight_tracks_flags[marker.track] = false;
@@ -586,10 +601,17 @@ void EuclideanBundleCommonIntrinsics(
586601
// Always set K3 constant, it's not used at the moment.
587602
constant_intrinsics.push_back(OFFSET_K3);
588603

604+
#if CERES_VERSION_MAJOR >= 3 || (CERES_VERSION_MAJOR >= 2 && CERES_VERSION_MINOR >= 1)
605+
ceres::SubsetManifold *subset_manifold =
606+
new ceres::SubsetManifold(OFFSET_MAX, constant_intrinsics);
607+
608+
problem.SetManifold(ceres_intrinsics, subset_manifold);
609+
#else
589610
ceres::SubsetParameterization *subset_parameterization =
590611
new ceres::SubsetParameterization(OFFSET_MAX, constant_intrinsics);
591612

592613
problem.SetParameterization(ceres_intrinsics, subset_parameterization);
614+
#endif
593615
}
594616

595617
// Configure the solver.

0 commit comments

Comments
 (0)