diff --git a/src/aliceVision/multiview/resection/resectionLORansac_test.cpp b/src/aliceVision/multiview/resection/resectionLORansac_test.cpp index afc6b49ee2..bcaffa525e 100644 --- a/src/aliceVision/multiview/resection/resectionLORansac_test.cpp +++ b/src/aliceVision/multiview/resection/resectionLORansac_test.cpp @@ -65,7 +65,7 @@ bool refinePoseAsItShouldbe(const Mat& pt3D, BundleAdjustmentCeres bundle_adjustment_obj; BundleAdjustment::ERefineOptions refineOptions = BundleAdjustment::REFINE_NONE; if (b_refine_pose) - refineOptions |= sfm::BundleAdjustment::REFINE_ROTATION | sfm::BundleAdjustment::REFINE_TRANSLATION; + refineOptions |= sfm::BundleAdjustment::REFINE_ROTATION | sfm::BundleAdjustment::REFINE_CENTER; if (b_refine_intrinsic) refineOptions |= sfm::BundleAdjustment::REFINE_INTRINSICS_ALL; const bool b_BA_Status = bundle_adjustment_obj.adjust(sfm_data, refineOptions); diff --git a/src/aliceVision/sfm/bundle/BundleAdjustment.hpp b/src/aliceVision/sfm/bundle/BundleAdjustment.hpp index ecc3988fde..069a0e7899 100644 --- a/src/aliceVision/sfm/bundle/BundleAdjustment.hpp +++ b/src/aliceVision/sfm/bundle/BundleAdjustment.hpp @@ -112,7 +112,7 @@ class BundleAdjustment { REFINE_NONE = 0, REFINE_ROTATION = 1, //< refine pose rotations - REFINE_TRANSLATION = 2, //< refine pose translations + REFINE_CENTER = 2, //< refine pose centers REFINE_STRUCTURE = 4, //< refine structure (i.e. 3D points) REFINE_INTRINSICS_FOCAL = 8, //< refine the focal length REFINE_INTRINSICS_OPTICALOFFSET_ALWAYS = 16, //< refine the optical offset from the center @@ -123,7 +123,7 @@ class BundleAdjustment /// Refine all intrinsics parameters REFINE_INTRINSICS_ALL = REFINE_INTRINSICS_FOCAL | REFINE_INTRINSICS_OPTICALOFFSET_IF_ENOUGH_DATA | REFINE_INTRINSICS_DISTORTION, /// Refine all parameters - REFINE_ALL = REFINE_ROTATION | REFINE_TRANSLATION | REFINE_INTRINSICS_ALL | REFINE_STRUCTURE, + REFINE_ALL = REFINE_ROTATION | REFINE_CENTER | REFINE_INTRINSICS_ALL | REFINE_STRUCTURE, }; /** diff --git a/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp b/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp index e6b6d0c1cd..fc87559fc6 100644 --- a/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp +++ b/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp @@ -226,21 +226,21 @@ void BundleAdjustmentCeres::addExtrinsicsToProblem(const sfmData::SfMData& sfmDa BundleAdjustment::ERefineOptions refineOptions, ceres::Problem& problem) { - const bool refineTranslation = refineOptions & BundleAdjustment::REFINE_TRANSLATION; + const bool refineCenter = refineOptions & BundleAdjustment::REFINE_CENTER; const bool refineRotation = refineOptions & BundleAdjustment::REFINE_ROTATION; const auto addPose = [&](const sfmData::CameraPose& cameraPose, bool isConstant, std::array& poseBlock) { const Mat3& R = cameraPose.getTransform().rotation(); - const Vec3& t = cameraPose.getTransform().translation(); + const Vec3& c = cameraPose.getTransform().center(); double angleAxis[3]; ceres::RotationMatrixToAngleAxis(static_cast(R.data()), angleAxis); poseBlock.at(0) = angleAxis[0]; poseBlock.at(1) = angleAxis[1]; poseBlock.at(2) = angleAxis[2]; - poseBlock.at(3) = t(0); - poseBlock.at(4) = t(1); - poseBlock.at(5) = t(2); + poseBlock.at(3) = c(0); + poseBlock.at(4) = c(1); + poseBlock.at(5) = c(2); double* poseBlockPtr = poseBlock.data(); problem.AddParameterBlock(poseBlockPtr, 6); @@ -249,7 +249,7 @@ void BundleAdjustmentCeres::addExtrinsicsToProblem(const sfmData::SfMData& sfmDa _allParametersBlocks.push_back(poseBlockPtr); // keep the camera extrinsics constants - if (cameraPose.isLocked() || isConstant || (!refineTranslation && !refineRotation)) + if (cameraPose.isLocked() || isConstant || (!refineCenter && !refineRotation)) { // set the whole parameter block as constant. _statistics.addState(EParameter::POSE, EEstimatorParameterState::CONSTANT); @@ -269,7 +269,7 @@ void BundleAdjustmentCeres::addExtrinsicsToProblem(const sfmData::SfMData& sfmDa } // don't refine translations - if (!refineTranslation) + if (!refineCenter) { constantExtrinsic.push_back(3); constantExtrinsic.push_back(4); @@ -1095,7 +1095,7 @@ void BundleAdjustmentCeres::resetProblem() void BundleAdjustmentCeres::updateFromSolution(sfmData::SfMData& sfmData, ERefineOptions refineOptions) const { - const bool refinePoses = (refineOptions & REFINE_ROTATION) || (refineOptions & REFINE_TRANSLATION); + const bool refinePoses = (refineOptions & REFINE_ROTATION) || (refineOptions & REFINE_CENTER); const bool refineIntrinsicsOpticalCenter = (refineOptions & REFINE_INTRINSICS_OPTICALOFFSET_ALWAYS) || (refineOptions & REFINE_INTRINSICS_OPTICALOFFSET_IF_ENOUGH_DATA); const bool refineIntrinsics = @@ -1130,10 +1130,11 @@ void BundleAdjustmentCeres::updateFromSolution(sfmData::SfMData& sfmData, ERefin Mat3 R_refined; ceres::AngleAxisToRotationMatrix(subPoseBlock.data(), R_refined.data()); - const Vec3 t_refined(subPoseBlock.at(3), subPoseBlock.at(4), subPoseBlock.at(5)); + const Vec3 c_refined(subPoseBlock.at(3), subPoseBlock.at(4), subPoseBlock.at(5)); // update the sub-pose - subPose.pose = poseFromRT(R_refined, t_refined); + subPose.pose.setRotation(R_refined); + subPose.pose.setCenter(c_refined); } } } diff --git a/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.hpp b/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.hpp index b54a9c561d..44a1b2ff60 100644 --- a/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.hpp +++ b/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.hpp @@ -261,7 +261,7 @@ class BundleAdjustmentCeres : public BundleAdjustment, ceres::EvaluationCallback /// all parameters blocks pointers std::vector _allParametersBlocks; /// poses blocks wrapper - /// block: ceres angleAxis(3) + translation(3) + /// block: ceres angleAxis(3) + center(3) std::map> _posesBlocks; // TODO : maybe we can use boost::flat_map instead of std::map ? /// intrinsics blocks wrapper /// block: intrinsics params diff --git a/src/aliceVision/sfm/bundle/bundleAdjustment_Enhanced_test.cpp b/src/aliceVision/sfm/bundle/bundleAdjustment_Enhanced_test.cpp index 112b95f200..6b4ef31131 100644 --- a/src/aliceVision/sfm/bundle/bundleAdjustment_Enhanced_test.cpp +++ b/src/aliceVision/sfm/bundle/bundleAdjustment_Enhanced_test.cpp @@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(test_poses) } sfm::BundleAdjustmentCeres::CeresOptions options; - sfm::BundleAdjustment::ERefineOptions refineOptions = sfm::BundleAdjustment::REFINE_ROTATION | sfm::BundleAdjustment::REFINE_TRANSLATION; + sfm::BundleAdjustment::ERefineOptions refineOptions = sfm::BundleAdjustment::REFINE_ROTATION | sfm::BundleAdjustment::REFINE_CENTER; options.summary = false; double rmseBefore = sfm::RMSE(sfmData); diff --git a/src/aliceVision/sfm/bundle/bundleAdjustment_temporalConstraint_test.cpp b/src/aliceVision/sfm/bundle/bundleAdjustment_temporalConstraint_test.cpp index 5d580abdc9..3318a3fdf0 100644 --- a/src/aliceVision/sfm/bundle/bundleAdjustment_temporalConstraint_test.cpp +++ b/src/aliceVision/sfm/bundle/bundleAdjustment_temporalConstraint_test.cpp @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(BA_temporalConstraint) sfm::BundleAdjustment::ERefineOptions refineOptions; refineOptions = sfm::BundleAdjustment::REFINE_ROTATION | sfm::BundleAdjustment::REFINE_STRUCTURE - | sfm::BundleAdjustment::REFINE_TRANSLATION + | sfm::BundleAdjustment::REFINE_CENTER | sfm::BundleAdjustment::REFINE_INTRINSICS_ALL; options.summary = false; diff --git a/src/aliceVision/sfm/bundle/costfunctions/depth.hpp b/src/aliceVision/sfm/bundle/costfunctions/depth.hpp index 37da049a6d..5b5436799c 100644 --- a/src/aliceVision/sfm/bundle/costfunctions/depth.hpp +++ b/src/aliceVision/sfm/bundle/costfunctions/depth.hpp @@ -32,14 +32,16 @@ struct DepthErrorFunctor // Apply external parameters (Pose) //-- const T* cam_R = parameter_pose; - const T* cam_t = ¶meter_pose[3]; + const T* cam_c = ¶meter_pose[3]; + T centeredPoint[3]; + centeredPoint[0] = parameter_point[0] - cam_c[0]; + centeredPoint[1] = parameter_point[1] - cam_c[1]; + centeredPoint[2] = parameter_point[2] - cam_c[2]; + T transformedPoint[3]; // Rotate the point according the camera rotation - ceres::AngleAxisRotatePoint(cam_R, parameter_point, transformedPoint); - - // Apply the camera translation - transformedPoint[2] += cam_t[2]; + ceres::AngleAxisRotatePoint(cam_R, centeredPoint, transformedPoint); residuals[0] = T(1.0 / _depthVariance) * (transformedPoint[2] - T(_depth)); diff --git a/src/aliceVision/sfm/bundle/costfunctions/projection.hpp b/src/aliceVision/sfm/bundle/costfunctions/projection.hpp index 56c6e02c8b..2e712b354f 100644 --- a/src/aliceVision/sfm/bundle/costfunctions/projection.hpp +++ b/src/aliceVision/sfm/bundle/costfunctions/projection.hpp @@ -40,16 +40,16 @@ struct ProjectionSimpleErrorFunctor // Apply external parameters (Pose) //-- const T* cam_R = parameter_pose; - const T* cam_t = ¶meter_pose[3]; + const T* cam_c = ¶meter_pose[3]; + T centeredPoint[3]; + centeredPoint[0] = parameter_point[0] - cam_c[0]; + centeredPoint[1] = parameter_point[1] - cam_c[1]; + centeredPoint[2] = parameter_point[2] - cam_c[2]; + T transformedPoint[3]; // Rotate the point according the camera rotation - ceres::AngleAxisRotatePoint(cam_R, parameter_point, transformedPoint); - - // Apply the camera translation - transformedPoint[0] += cam_t[0]; - transformedPoint[1] += cam_t[1]; - transformedPoint[2] += cam_t[2]; + ceres::AngleAxisRotatePoint(cam_R, centeredPoint, transformedPoint); const T * innerParameters[3]; innerParameters[0] = parameter_intrinsics; @@ -112,29 +112,28 @@ struct ProjectionErrorFunctor T transformedPoint[3]; { const T* cam_R = parameter_pose; - const T* cam_t = ¶meter_pose[3]; + const T* cam_c = ¶meter_pose[3]; - // Rotate the point according the camera rotation - ceres::AngleAxisRotatePoint(cam_R, parameter_point, transformedPoint); + T centeredPoint[3]; + centeredPoint[0] = parameter_point[0] - cam_c[0]; + centeredPoint[1] = parameter_point[1] - cam_c[1]; + centeredPoint[2] = parameter_point[2] - cam_c[2]; - // Apply the camera translation - transformedPoint[0] += cam_t[0]; - transformedPoint[1] += cam_t[1]; - transformedPoint[2] += cam_t[2]; + // Rotate the point according the camera rotation + ceres::AngleAxisRotatePoint(cam_R, centeredPoint, transformedPoint); } { const T* cam_R = parameter_subpose; - const T* cam_t = ¶meter_subpose[3]; + const T* cam_c = ¶meter_subpose[3]; - // Rotate the point according to the camera rotation - T transformedPointBuf[3] = {transformedPoint[0], transformedPoint[1], transformedPoint[2]}; - ceres::AngleAxisRotatePoint(cam_R, transformedPointBuf, transformedPoint); + T centeredPoint[3]; + centeredPoint[0] = transformedPoint[0] - cam_c[0]; + centeredPoint[1] = transformedPoint[1] - cam_c[1]; + centeredPoint[2] = transformedPoint[2] - cam_c[2]; - // Apply the camera translation - transformedPoint[0] += cam_t[0]; - transformedPoint[1] += cam_t[1]; - transformedPoint[2] += cam_t[2]; + // Rotate the point according to the camera rotation + ceres::AngleAxisRotatePoint(cam_R, centeredPoint, transformedPoint); } const T * innerParameters[3]; @@ -212,6 +211,12 @@ struct ProjectionRelativeErrorFunctor const T* parameter_refpose = parameters[3]; const T* parameter_relativepoint = parameters[4]; + /// (cam_T_world) * (ref_T_world)^-1 * ref_p + /// cam_R_world * (ref_R_world^T * ref_p - ref_R_world^T * ref_t_world) + cam_t_world + /// cam_R_world * (ref_R_world^T * ref_p + ref_c_world) + cam_t_world + /// cam_R_world * (ref_R_world^T * ref_p + ref_c_world) - cam_R_world * cam_c_world + /// cam_R_world * (ref_R_world^T * ref_p + ref_c_world - cam_c_world) + //Retrieve point T relpoint[3]; relpoint[0] = parameter_relativepoint[0]; @@ -219,15 +224,11 @@ struct ProjectionRelativeErrorFunctor relpoint[2] = parameter_relativepoint[2]; const T* refcam_R = parameter_refpose; - const T* refcam_t = ¶meter_refpose[3]; + const T* refcam_c = ¶meter_refpose[3]; // Apply transformation such that the point // Which was defined in the camera geometric frame // is now defined in the world frame - relpoint[0] = relpoint[0] - refcam_t[0]; - relpoint[1] = relpoint[1] - refcam_t[1]; - relpoint[2] = relpoint[2] - refcam_t[2]; - T invrefcam_R[3]; invrefcam_R[0] = -refcam_R[0]; invrefcam_R[1] = -refcam_R[1]; @@ -236,20 +237,22 @@ struct ProjectionRelativeErrorFunctor T absolutePoint[3]; ceres::AngleAxisRotatePoint(invrefcam_R, relpoint, absolutePoint); + absolutePoint[0] += refcam_c[0]; + absolutePoint[1] += refcam_c[1]; + absolutePoint[2] += refcam_c[2]; + //-- // Apply external parameters (Pose) //-- const T* cam_R = parameter_pose; - const T* cam_t = ¶meter_pose[3]; - + const T* cam_c = ¶meter_pose[3]; + absolutePoint[0] -= cam_c[0]; + absolutePoint[1] -= cam_c[1]; + absolutePoint[2] -= cam_c[2]; + // Rotate the point according the camera rotation ceres::AngleAxisRotatePoint(cam_R, absolutePoint, transformedPoint); - - // Apply the camera translation - transformedPoint[0] += cam_t[0]; - transformedPoint[1] += cam_t[1]; - transformedPoint[2] += cam_t[2]; } const T * innerParameters[3]; diff --git a/src/aliceVision/sfm/bundle/costfunctions/projectionMesh.hpp b/src/aliceVision/sfm/bundle/costfunctions/projectionMesh.hpp index 49b2c8bf77..ea5b9836d8 100644 --- a/src/aliceVision/sfm/bundle/costfunctions/projectionMesh.hpp +++ b/src/aliceVision/sfm/bundle/costfunctions/projectionMesh.hpp @@ -47,9 +47,9 @@ struct ProjectionMeshErrorFunctor const T* refcam_r_world = parameter_referencePose; - const T* refcam_t_world = ¶meter_referencePose[3]; + const T* world_t_refcam = ¶meter_referencePose[3]; const T* curcam_r_world = parameter_currentPose; - const T* curcam_t_world = ¶meter_currentPose[3]; + const T* wolrd_t_curcam = ¶meter_currentPose[3]; T world_r_refcam[3]; world_r_refcam[0] = -refcam_r_world[0]; @@ -64,13 +64,6 @@ struct ProjectionMeshErrorFunctor refcam_point[1] = parameter_point[1] / norm; refcam_point[2] = 1.0 / norm; - // Compute c = - R^t * t - T c[3]; - ceres::AngleAxisRotatePoint(world_r_refcam, refcam_t_world, c); - c[0] = -c[0]; - c[1] = -c[1]; - c[2] = -c[2]; - // Compute direction = R^t reference_point T direction[3]; ceres::AngleAxisRotatePoint(world_r_refcam, refcam_point, direction); @@ -78,7 +71,7 @@ struct ProjectionMeshErrorFunctor T worldPoint[3]; const T * intersectParameters[2]; - intersectParameters[0] = c; + intersectParameters[0] = world_t_refcam; intersectParameters[1] = direction; if (!_meshIntersectFunctor(intersectParameters, worldPoint)) { @@ -87,10 +80,10 @@ struct ProjectionMeshErrorFunctor // Compute point in camera coordinates T transformedPoint[3]; + worldPoint[0] -= wolrd_t_curcam[0]; + worldPoint[1] -= wolrd_t_curcam[1]; + worldPoint[2] -= wolrd_t_curcam[2]; ceres::AngleAxisRotatePoint(curcam_r_world, worldPoint, transformedPoint); - transformedPoint[0] += curcam_t_world[0]; - transformedPoint[1] += curcam_t_world[1]; - transformedPoint[2] += curcam_t_world[2]; // Project const T * innerParameters[3]; diff --git a/src/aliceVision/sfm/bundle/costfunctions/survey.hpp b/src/aliceVision/sfm/bundle/costfunctions/survey.hpp index efe4137e3e..cfb0b30340 100644 --- a/src/aliceVision/sfm/bundle/costfunctions/survey.hpp +++ b/src/aliceVision/sfm/bundle/costfunctions/survey.hpp @@ -39,16 +39,16 @@ struct SurveyErrorFunctor // Apply external parameters (Pose) //-- const T* cam_R = parameter_pose; - const T* cam_t = ¶meter_pose[3]; + const T* cam_c = ¶meter_pose[3]; + T centeredPoint[3]; + centeredPoint[0] = parameter_point[0] - cam_c[0]; + centeredPoint[1] = parameter_point[1] - cam_c[1]; + centeredPoint[2] = parameter_point[2] - cam_c[2]; + T transformedPoint[3]; // Rotate the point according the camera rotation - ceres::AngleAxisRotatePoint(cam_R, parameter_point, transformedPoint); - - // Apply the camera translation - transformedPoint[0] += cam_t[0]; - transformedPoint[1] += cam_t[1]; - transformedPoint[2] += cam_t[2]; + ceres::AngleAxisRotatePoint(cam_R, centeredPoint, transformedPoint); const T * innerParameters[3]; innerParameters[0] = parameter_intrinsics; diff --git a/src/aliceVision/sfm/bundle/costfunctions/temporalConstraint.hpp b/src/aliceVision/sfm/bundle/costfunctions/temporalConstraint.hpp index ba9a880fa9..3c0790fea0 100644 --- a/src/aliceVision/sfm/bundle/costfunctions/temporalConstraint.hpp +++ b/src/aliceVision/sfm/bundle/costfunctions/temporalConstraint.hpp @@ -60,22 +60,18 @@ struct TemporalConstraintFunctor invQuaternion[3] = -quaternion[3]; }; - const auto viewPreProcess = [&](const T* angleAxis, const T* translation, T* viewCenter, T* quaternion) - { - T invQuaternion[4]; - ceres::AngleAxisToQuaternion(angleAxis, quaternion); - // Inverse the rotation to compute the camera position - quaternionConjugate(quaternion, invQuaternion); - ceres::QuaternionRotatePoint(invQuaternion, translation, viewCenter); - }; - T viewCenter0[3], viewCenter1[3], viewCenter2[3], viewCenter3[3]; - T quaternion0[4], quaternion1[4], quaternion2[4], quaternion3[4]; - viewPreProcess(¶0[0], ¶0[3], viewCenter0, quaternion0); - viewPreProcess(¶1[0], ¶1[3], viewCenter1, quaternion1); - viewPreProcess(¶2[0], ¶2[3], viewCenter2, quaternion2); - viewPreProcess(¶3[0], ¶3[3], viewCenter3, quaternion3); + T quaternion0[4], quaternion1[4], quaternion2[4], quaternion3[4]; + ceres::AngleAxisToQuaternion(¶0[0], quaternion0); + ceres::AngleAxisToQuaternion(¶1[0], quaternion1); + ceres::AngleAxisToQuaternion(¶2[0], quaternion2); + ceres::AngleAxisToQuaternion(¶3[0], quaternion3); + + const T * viewCenter0 = ¶0[3]; + const T * viewCenter1 = ¶1[3]; + const T * viewCenter2 = ¶2[3]; + const T * viewCenter3 = ¶3[3]; const auto computeAngleDiff = [&](const T* quaternionA, const T* quaternionB, T* angleAxisDiff, T* quaternionDiff) { diff --git a/src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp b/src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp index 09ee6c8a4d..e410503472 100644 --- a/src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp +++ b/src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp @@ -22,7 +22,7 @@ bool SfmBundle::process(sfmData::SfMData & sfmData, const track::TracksHandler & BundleAdjustment::ERefineOptions refineOptions = BundleAdjustment::REFINE_NONE; refineOptions |= BundleAdjustment::REFINE_ROTATION; - refineOptions |= BundleAdjustment::REFINE_TRANSLATION; + refineOptions |= BundleAdjustment::REFINE_CENTER; if (_isStructureRefinementEnabled) { diff --git a/src/aliceVision/sfm/pipeline/expanding/SfmResection.cpp b/src/aliceVision/sfm/pipeline/expanding/SfmResection.cpp index e4adf6e127..3ae470543d 100644 --- a/src/aliceVision/sfm/pipeline/expanding/SfmResection.cpp +++ b/src/aliceVision/sfm/pipeline/expanding/SfmResection.cpp @@ -180,7 +180,7 @@ bool SfmResection::internalRefinement( } BundleAdjustmentCeres BA; - BundleAdjustment::ERefineOptions refineOptions = BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_TRANSLATION; + BundleAdjustment::ERefineOptions refineOptions = BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_CENTER; const bool success = BA.adjust(tinyScene, refineOptions); if(!success) diff --git a/src/aliceVision/sfm/pipeline/global/GlobalSfMTranslationAveragingSolver.cpp b/src/aliceVision/sfm/pipeline/global/GlobalSfMTranslationAveragingSolver.cpp index 45de689ad3..cbc80755f1 100644 --- a/src/aliceVision/sfm/pipeline/global/GlobalSfMTranslationAveragingSolver.cpp +++ b/src/aliceVision/sfm/pipeline/global/GlobalSfMTranslationAveragingSolver.cpp @@ -721,7 +721,7 @@ bool GlobalSfMTranslationAveragingSolver::estimateTTriplet(const SfMData& sfmDat BundleAdjustmentCeres::BA_options options(false, false); options._linear_solver_type = ceres::SPARSE_SCHUR; BundleAdjustmentCeres bundleAdjustmentObj(options); - if (bundleAdjustmentObj.Adjust(tiny_scene, REFINE_TRANSLATION | REFINE_STRUCTURE)) + if (bundleAdjustmentObj.adjust(tinyScene, REFINE_CENTER | REFINE_STRUCTURE)) { // export scene for visualization std::ostringstream os; diff --git a/src/aliceVision/sfm/pipeline/global/ReconstructionEngine_globalSfM.cpp b/src/aliceVision/sfm/pipeline/global/ReconstructionEngine_globalSfM.cpp index 946a690023..d664fc74d7 100644 --- a/src/aliceVision/sfm/pipeline/global/ReconstructionEngine_globalSfM.cpp +++ b/src/aliceVision/sfm/pipeline/global/ReconstructionEngine_globalSfM.cpp @@ -375,8 +375,8 @@ bool ReconstructionEngine_globalSfM::adjust() options.useParametersOrdering = false; // disable parameters ordering BundleAdjustmentCeres BA(options); - // - refine only Structure and translations - bool success = BA.adjust(_sfmData, BundleAdjustment::REFINE_TRANSLATION | BundleAdjustment::REFINE_STRUCTURE); + // - refine only Structure and centers + bool success = BA.adjust(_sfmData, BundleAdjustment::REFINE_CENTER | BundleAdjustment::REFINE_STRUCTURE); if (success) { if (!_loggingFile.empty()) @@ -385,7 +385,7 @@ bool ReconstructionEngine_globalSfM::adjust() sfmDataIO::ESfMData(sfmDataIO::EXTRINSICS | sfmDataIO::STRUCTURE)); // refine only structure and rotations & translations - success = BA.adjust(_sfmData, BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_TRANSLATION | BundleAdjustment::REFINE_STRUCTURE); + success = BA.adjust(_sfmData, BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_CENTER | BundleAdjustment::REFINE_STRUCTURE); if (success && !_loggingFile.empty()) sfmDataIO::save(_sfmData, @@ -437,7 +437,7 @@ bool ReconstructionEngine_globalSfM::adjust() } BundleAdjustment::ERefineOptions refineOptions = - BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_TRANSLATION | BundleAdjustment::REFINE_STRUCTURE; + BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_CENTER | BundleAdjustment::REFINE_STRUCTURE; if (!_lockAllIntrinsics) refineOptions |= BundleAdjustment::REFINE_INTRINSICS_ALL; success = BA.adjust(_sfmData, refineOptions); @@ -611,7 +611,7 @@ void ReconstructionEngine_globalSfM::computeRelativeRotations(rotationAveraging: options.linearSolverType = ceres::DENSE_SCHUR; BundleAdjustmentCeres bundleAdjustmentObj(options); if (bundleAdjustmentObj.adjust( - tinyScene, BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_TRANSLATION | BundleAdjustment::REFINE_STRUCTURE)) + tinyScene, BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_CENTER | BundleAdjustment::REFINE_STRUCTURE)) { // --> to debug: save relative pair geometry on disk // std::ostringstream os; diff --git a/src/aliceVision/sfm/pipeline/localization/SfMLocalizer.cpp b/src/aliceVision/sfm/pipeline/localization/SfMLocalizer.cpp index 26a41ca153..a0f0ab28d5 100644 --- a/src/aliceVision/sfm/pipeline/localization/SfMLocalizer.cpp +++ b/src/aliceVision/sfm/pipeline/localization/SfMLocalizer.cpp @@ -216,7 +216,7 @@ bool SfMLocalizer::refinePose(camera::IntrinsicBase* intrinsics, BundleAdjustment::ERefineOptions refineOptions = BundleAdjustment::REFINE_NONE; if (refinePose) - refineOptions |= BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_TRANSLATION; + refineOptions |= BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_CENTER; if (refineIntrinsic) refineOptions |= BundleAdjustment::REFINE_INTRINSICS_ALL; diff --git a/src/aliceVision/sfm/pipeline/sequential/ReconstructionEngine_sequentialSfM.cpp b/src/aliceVision/sfm/pipeline/sequential/ReconstructionEngine_sequentialSfM.cpp index 9c75eacb06..097f8c9c3c 100644 --- a/src/aliceVision/sfm/pipeline/sequential/ReconstructionEngine_sequentialSfM.cpp +++ b/src/aliceVision/sfm/pipeline/sequential/ReconstructionEngine_sequentialSfM.cpp @@ -687,7 +687,7 @@ bool ReconstructionEngine_sequentialSfM::bundleAdjustment(std::set& newR BundleAdjustmentCeres::CeresOptions options; BundleAdjustment::ERefineOptions refineOptions = - BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_TRANSLATION | BundleAdjustment::REFINE_STRUCTURE; + BundleAdjustment::REFINE_ROTATION | BundleAdjustment::REFINE_CENTER | BundleAdjustment::REFINE_STRUCTURE; if (!isInitialPair && !_params.lockAllIntrinsics) refineOptions |= BundleAdjustment::REFINE_INTRINSICS_ALL; diff --git a/src/aliceVision/sfmData/CameraPose.hpp b/src/aliceVision/sfmData/CameraPose.hpp index 31ef1abf2e..9c5c36c3c3 100644 --- a/src/aliceVision/sfmData/CameraPose.hpp +++ b/src/aliceVision/sfmData/CameraPose.hpp @@ -128,12 +128,12 @@ class CameraPose } const Vec3 r_refined(data.at(0), data.at(1), data.at(2)); - const Vec3 t_refined(data.at(3), data.at(4), data.at(5)); + const Vec3 c_refined(data.at(3), data.at(4), data.at(5)); const Mat3 R_refined = SO3::expm(r_refined); // update the pose - setTransform(geometry::poseFromRT(R_refined, t_refined)); + setTransform(geometry::Pose3(R_refined, c_refined)); } private: diff --git a/src/software/pipeline/main_checkerboardCalibration.cpp b/src/software/pipeline/main_checkerboardCalibration.cpp index f9a90f2ab1..f29b11048c 100644 --- a/src/software/pipeline/main_checkerboardCalibration.cpp +++ b/src/software/pipeline/main_checkerboardCalibration.cpp @@ -344,7 +344,7 @@ bool estimateIntrinsicsPoses(sfmData::SfMData& sfmData, std::map