From 190c30fd22a6c8d1fbeb09a93af1d9eeb1b335d0 Mon Sep 17 00:00:00 2001 From: Jhacson Meza Date: Fri, 21 Mar 2025 11:29:19 +0100 Subject: [PATCH] Check if value is set to avoid out-of-bound indexing --- glomap/estimators/bundle_adjustment.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/glomap/estimators/bundle_adjustment.cc b/glomap/estimators/bundle_adjustment.cc index 57f85b13..0e5ee5d3 100644 --- a/glomap/estimators/bundle_adjustment.cc +++ b/glomap/estimators/bundle_adjustment.cc @@ -208,11 +208,13 @@ void BundleAdjuster::ParameterizeVariables( } } - // Set the first camera to be fixed to remove the gauge ambiguity. - problem_->SetParameterBlockConstant( - images[center].cam_from_world.rotation.coeffs().data()); - problem_->SetParameterBlockConstant( - images[center].cam_from_world.translation.data()); + if (counter > 0) { + // Set the first camera to be fixed to remove the gauge ambiguity. + problem_->SetParameterBlockConstant( + images[center].cam_from_world.rotation.coeffs().data()); + problem_->SetParameterBlockConstant( + images[center].cam_from_world.translation.data()); + } // Parameterize the camera parameters, or set them to be constant if desired if (options_.optimize_intrinsics && !options_.optimize_principal_point) {