Skip to content

Commit e3044bf

Browse files
author
Fabien Servant
committed
Point were distorted twice in cost function
1 parent 2be1e77 commit e3044bf

File tree

1 file changed

+2
-38
lines changed

1 file changed

+2
-38
lines changed

src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,7 @@ using namespace aliceVision::geometry;
3737
*/
3838
ceres::CostFunction* createCostFunctionFromIntrinsics(const std::shared_ptr<IntrinsicBase> intrinsic, const sfmData::Observation& observation)
3939
{
40-
// Apply undistortion to observation
41-
sfmData::Observation obsUndistorted = observation;
42-
std::shared_ptr<camera::IntrinsicScaleOffsetDisto> intrinsicDistortion = std::dynamic_pointer_cast<camera::IntrinsicScaleOffsetDisto>(intrinsic);
43-
if (intrinsicDistortion)
44-
{
45-
auto undistortion = intrinsicDistortion->getUndistortion();
46-
if (undistortion)
47-
{
48-
obsUndistorted.setCoordinates(undistortion->undistort(observation.getCoordinates()));
49-
50-
if (intrinsicDistortion->getDistortion() != nullptr)
51-
{
52-
throw std::runtime_error("Distortion should not be there when undistortion exists");
53-
}
54-
}
55-
}
56-
57-
58-
auto costFunction = new ceres::DynamicAutoDiffCostFunction<ProjectionSimpleErrorFunctor>(new ProjectionSimpleErrorFunctor(obsUndistorted, intrinsic));
40+
auto costFunction = new ceres::DynamicAutoDiffCostFunction<ProjectionSimpleErrorFunctor>(new ProjectionSimpleErrorFunctor(observation, intrinsic));
5941

6042
costFunction->AddParameterBlock(intrinsic->getParams().size());
6143
costFunction->AddParameterBlock(6);
@@ -73,25 +55,7 @@ ceres::CostFunction* createCostFunctionFromIntrinsics(const std::shared_ptr<Intr
7355
*/
7456
ceres::CostFunction* createRigCostFunctionFromIntrinsics(std::shared_ptr<IntrinsicBase> intrinsic, const sfmData::Observation& observation)
7557
{
76-
// Apply undistortion to observation
77-
sfmData::Observation obsUndistorted = observation;
78-
std::shared_ptr<camera::IntrinsicScaleOffsetDisto> intrinsicDistortion = std::dynamic_pointer_cast<camera::IntrinsicScaleOffsetDisto>(intrinsic);
79-
if (intrinsicDistortion)
80-
{
81-
auto undistortion = intrinsicDistortion->getUndistortion();
82-
if (undistortion)
83-
{
84-
obsUndistorted.setCoordinates(undistortion->undistort(observation.getCoordinates()));
85-
86-
if (intrinsicDistortion->getDistortion() != nullptr)
87-
{
88-
throw std::runtime_error("Distortion should not be there when undistortion exists");
89-
}
90-
}
91-
}
92-
93-
94-
auto costFunction = new ceres::DynamicAutoDiffCostFunction<ProjectionErrorFunctor>(new ProjectionErrorFunctor(obsUndistorted, intrinsic));
58+
auto costFunction = new ceres::DynamicAutoDiffCostFunction<ProjectionErrorFunctor>(new ProjectionErrorFunctor(observation, intrinsic));
9559

9660
costFunction->AddParameterBlock(intrinsic->getParams().size());
9761
costFunction->AddParameterBlock(6);

0 commit comments

Comments
 (0)