@@ -236,10 +236,8 @@ bool refineSequence(std::vector<LocalizationResult>& vec_localizationResult,
236236 // just debugging stuff
237237 if (allTheSameIntrinsics)
238238 {
239- std::vector<double > params = tinyScene.getIntrinsics ().at (0 ). get () ->getParameters ();
239+ std::vector<double > params = tinyScene.getIntrinsics ().at (0 )->getParameters ();
240240 ALICEVISION_LOG_DEBUG (" K before bundle: " << params[0 ] << " " << params[1 ] << " " << params[2 ]);
241- if (params.size () == 6 )
242- ALICEVISION_LOG_DEBUG (" Distortion before bundle: " << params[3 ] << " " << params[4 ] << " " << params[5 ]);
243241 }
244242 }
245243
@@ -302,20 +300,19 @@ bool refineSequence(std::vector<LocalizationResult>& vec_localizationResult,
302300 // if we used the same intrinsics for all the localization results we need to
303301 // update the intrinsics of each localization result
304302
305- // get its optimized parameters
306- std::vector< double > params = tinyScene. getIntrinsics (). at ( 0 ). get ()-> getParameters ( );
307- ALICEVISION_LOG_DEBUG ( " Type of intrinsics " << tinyScene. getIntrinsics (). at ( 0 ). get ()-> getType ()) ;
308- if (params. size () == 4 )
303+ auto intrinsic = tinyScene. getIntrinsics (). at ( 0 );
304+ auto casted = camera::IntrinsicScaleOffsetDisto::cast (intrinsic );
305+ std::shared_ptr<camera::Distortion> distortion ;
306+ if (casted )
309307 {
310- // this means that the b_no_distortion has been passed
311- // set distortion to 0
312- params.push_back (0 );
313- params.push_back (0 );
314- params.push_back (0 );
308+ distortion = casted->getDistortion ();
315309 }
316- assert (params.size () == 6 );
310+
311+ // get its optimized parameters
312+ std::vector<double > params = intrinsic->getParameters ();
313+
314+ ALICEVISION_LOG_DEBUG (" Type of intrinsics " << intrinsic->getType ());
317315 ALICEVISION_LOG_DEBUG (" K after bundle: " << params[0 ] << " " << params[1 ] << " " << params[2 ] << " " << params[3 ]);
318- ALICEVISION_LOG_DEBUG (" Distortion after bundle " << params[4 ] << " " << params[5 ] << " " << params[6 ]);
319316
320317 // update the intrinsics of the each localization result
321318 for (size_t viewID = 0 ; viewID < numViews; ++viewID)
@@ -327,6 +324,13 @@ bool refineSequence(std::vector<LocalizationResult>& vec_localizationResult,
327324 }
328325 currResult.updateIntrinsics (params);
329326
327+ auto curDistortion = currResult.getIntrinsics ().getDistortion ();
328+ if (distortion && curDistortion)
329+ {
330+ curDistortion->setParameters (distortion->getParameters ());
331+ }
332+
333+
330334 // just debugging -- print reprojection errors
331335 const Mat2X residuals = currResult.computeInliersResiduals ();
332336
0 commit comments