diff --git a/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp b/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp index 8ca68819c4..554605b049 100644 --- a/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp +++ b/src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp @@ -224,7 +224,7 @@ ceres::CostFunction* createCostFunctionFromIntrinsics(const IntrinsicBase* intri return new ceres::AutoDiffCostFunction( new ResidualErrorFunctor_Pinhole3DEClassicLD(w, h, obsUndistorted)); case EINTRINSIC::PINHOLE_CAMERA_3DEANAMORPHIC4: - return new ceres::AutoDiffCostFunction(new ResidualErrorFunctor_Pinhole(w, h, obsUndistorted)); + return new ceres::AutoDiffCostFunction(new ResidualErrorFunctor_Pinhole(w, h, obsUndistorted)); case EINTRINSIC::PINHOLE_CAMERA_BROWN: return new ceres::AutoDiffCostFunction( new ResidualErrorFunctor_PinholeBrownT2(w, h, obsUndistorted)); diff --git a/src/aliceVision/sfmDataIO/AlembicImporter.cpp b/src/aliceVision/sfmDataIO/AlembicImporter.cpp index 3ff2f418a4..47602b4949 100644 --- a/src/aliceVision/sfmDataIO/AlembicImporter.cpp +++ b/src/aliceVision/sfmDataIO/AlembicImporter.cpp @@ -621,11 +621,15 @@ bool readCamera(const Version& abcVersion, { distortion->setParameters(distortionParams); } + + std::shared_ptr undistortion = intrinsicCasted->getUndistortion(); if (undistortion) { undistortion->setParameters(undistortionParams); undistortion->setOffset(undistortionOffset); + //If undistortion exists, distortion does not + intrinsicCasted->setDistortionObject(nullptr); } } diff --git a/src/aliceVision/sfmDataIO/jsonIO.cpp b/src/aliceVision/sfmDataIO/jsonIO.cpp index 383cbfbad3..0ed9292aa5 100644 --- a/src/aliceVision/sfmDataIO/jsonIO.cpp +++ b/src/aliceVision/sfmDataIO/jsonIO.cpp @@ -342,22 +342,6 @@ void loadIntrinsic(const Version& version, IndexT& intrinsicId, std::shared_ptr< intrinsicWithDistoEnabled->setDistortionInitializationMode(distortionInitializationMode); - std::shared_ptr distortionObject = intrinsicWithDistoEnabled->getDistortion(); - if (distortionObject) - { - std::vector distortionParams; - for (bpt::ptree::value_type& paramNode : intrinsicTree.get_child("distortionParams")) - { - distortionParams.emplace_back(paramNode.second.get_value()); - } - - // ensure that we have the right number of params - if (distortionParams.size() == distortionObject->getParameters().size()) - { - distortionObject->setParameters(distortionParams); - } - } - std::shared_ptr undistortionObject = intrinsicWithDistoEnabled->getUndistortion(); if (undistortionObject) { @@ -375,6 +359,25 @@ void loadIntrinsic(const Version& version, IndexT& intrinsicId, std::shared_ptr< loadMatrix("undistortionOffset", offset, intrinsicTree); undistortionObject->setOffset(offset); } + + //If undistortion exists, distortion does not + intrinsicWithDistoEnabled->setDistortionObject(nullptr); + } + + std::shared_ptr distortionObject = intrinsicWithDistoEnabled->getDistortion(); + if (distortionObject) + { + std::vector distortionParams; + for (bpt::ptree::value_type& paramNode : intrinsicTree.get_child("distortionParams")) + { + distortionParams.emplace_back(paramNode.second.get_value()); + } + + // ensure that we have the right number of params + if (distortionParams.size() == distortionObject->getParameters().size()) + { + distortionObject->setParameters(distortionParams); + } } }