@@ -342,22 +342,6 @@ void loadIntrinsic(const Version& version, IndexT& intrinsicId, std::shared_ptr<
342
342
343
343
intrinsicWithDistoEnabled->setDistortionInitializationMode (distortionInitializationMode);
344
344
345
- std::shared_ptr<camera::Distortion> distortionObject = intrinsicWithDistoEnabled->getDistortion ();
346
- if (distortionObject)
347
- {
348
- std::vector<double > distortionParams;
349
- for (bpt::ptree::value_type& paramNode : intrinsicTree.get_child (" distortionParams" ))
350
- {
351
- distortionParams.emplace_back (paramNode.second .get_value <double >());
352
- }
353
-
354
- // ensure that we have the right number of params
355
- if (distortionParams.size () == distortionObject->getParameters ().size ())
356
- {
357
- distortionObject->setParameters (distortionParams);
358
- }
359
- }
360
-
361
345
std::shared_ptr<camera::Undistortion> undistortionObject = intrinsicWithDistoEnabled->getUndistortion ();
362
346
if (undistortionObject)
363
347
{
@@ -375,6 +359,25 @@ void loadIntrinsic(const Version& version, IndexT& intrinsicId, std::shared_ptr<
375
359
loadMatrix (" undistortionOffset" , offset, intrinsicTree);
376
360
undistortionObject->setOffset (offset);
377
361
}
362
+
363
+ // If undistortion exists, distortion does not
364
+ intrinsicWithDistoEnabled->setDistortionObject (nullptr );
365
+ }
366
+
367
+ std::shared_ptr<camera::Distortion> distortionObject = intrinsicWithDistoEnabled->getDistortion ();
368
+ if (distortionObject)
369
+ {
370
+ std::vector<double > distortionParams;
371
+ for (bpt::ptree::value_type& paramNode : intrinsicTree.get_child (" distortionParams" ))
372
+ {
373
+ distortionParams.emplace_back (paramNode.second .get_value <double >());
374
+ }
375
+
376
+ // ensure that we have the right number of params
377
+ if (distortionParams.size () == distortionObject->getParameters ().size ())
378
+ {
379
+ distortionObject->setParameters (distortionParams);
380
+ }
378
381
}
379
382
}
380
383
0 commit comments