@@ -111,20 +111,28 @@ void cIrbComp_Block::AddImagePose(const std::string & aNameIm,bool okImNotInBlo
111111std::pair<tPoseR,cIrb_SigmaPoseRel> cIrbComp_Block::ComputeCalibCamsInit (int aKC1,int aKC2) const
112112{
113113 // [0] Compute relative poses for each time stamps where it exist
114- std::vector<tPoseR> aVPoseRel; // vector of relative pose
115- std::vector<std::string> aVTS;
116- for (const auto & [aName,aDataTS] : mDataTS )
114+ std::vector<tPoseR> aVPoseRel; // vector of existing relative pose
115+ std::vector<std::string> aVTS; // vector of existing time_stamp
116+ for (const auto & [aName,aDataTS] : mDataTS ) // parse Time-Stamps and data associated
117117 {
118- const cIrbComp_CamSet & aSetC = aDataTS.SetCams ();
118+ const cIrbComp_CamSet & aSetC = aDataTS.SetCams (); // extract data for cameras
119119 if (aSetC.HasPoseRel (aKC1,aKC2))
120120 {
121121 tPoseR aPose = aSetC.PoseRel (aKC1,aKC2);
122122 aVPoseRel.push_back (aPose);
123123 aVTS.push_back (aName);
124124 }
125125 }
126-
127- // [1] Compute medians, used to have an order of magnitude
126+ int aNbP = aVPoseRel.size ();
127+ if (aNbP<2 )
128+ return std::pair<tPoseR,cIrb_SigmaPoseRel>
129+ (
130+ tPoseR::RandomIsom3D (1e20 ),
131+ cIrb_SigmaPoseRel ()
132+ );
133+
134+ // [1] Compute medians of residuals, used to have an order of magnitude of the sigmas
135+ // required for mixing sigma on tr with sigma on rot
128136 tREAL8 aMedTr=0 ,aMedRot=0 ;
129137 {
130138 std::vector<tREAL8> aVDistTr;
@@ -142,7 +150,8 @@ std::pair<tPoseR,cIrb_SigmaPoseRel> cIrbComp_Block::ComputeCalibCamsInit(int aKC
142150 }
143151
144152
145- // [2] Exract the robust center
153+ // [2] Exract the robust center, ie the one minimizing the sum of distance
154+ // to the other
146155 int aK1Min = -1 ;
147156 tREAL8 aMinDGlob = 1e10 ;
148157 tREAL8 aMinDTr = 1e10 ;
@@ -171,9 +180,9 @@ std::pair<tPoseR,cIrb_SigmaPoseRel> cIrbComp_Block::ComputeCalibCamsInit(int aKC
171180 aMinDRot = aSumDRot ;
172181 }
173182 }
174- aMinDGlob /= aVPoseRel. size ( ) ;
175- aMinDTr /= aVPoseRel. size ( ) ;
176- aMinDRot /= aVPoseRel. size ( ) ;
183+ aMinDGlob /= (aNbP- 1 ) ;
184+ aMinDTr /= (aNbP- 1 ) ;
185+ aMinDRot /= (aNbP- 1 ) ;
177186
178187 /*
179188 StdOut() << "K1/K2=" << aKC1<< aKC2
@@ -185,7 +194,7 @@ std::pair<tPoseR,cIrb_SigmaPoseRel> cIrbComp_Block::ComputeCalibCamsInit(int aKC
185194 return std::pair<tPoseR,cIrb_SigmaPoseRel>
186195 (
187196 aVPoseRel.at (aK1Min),
188- cIrb_SigmaPoseRel (aKC1,aKC2,aMinDTr,aMinDRot)
197+ cIrb_SigmaPoseRel (aKC1,aKC2,aNbP,aMinDGlob, aMinDTr,aMinDRot)
189198 );
190199}
191200
@@ -328,10 +337,10 @@ class cAppli_EditBlockInstr : public cMMVII_Appli
328337 std::vector<std::string> Samples () const override ;
329338
330339 private :
331- cPhotogrammetricProject mPhProj ;
332- std::string mNameBloc ;
333- std::vector<std::string> mVPatsIm4Cam ;
334- bool mFromScratch ;
340+ cPhotogrammetricProject mPhProj ; // < As usual ....
341+ std::string mNameBloc ; // < Name of the block edited (generally default MMVII)
342+ std::vector<std::string> mVPatsIm4Cam ; // < Patterns for cam structure : [PatSelOnDisk,PatTimeStamp?,PatSelInBlock?]
343+ bool mFromScratch ; // < If exist file : Reset of Modify ?
335344};
336345
337346cAppli_EditBlockInstr::cAppli_EditBlockInstr (const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) :
@@ -378,23 +387,31 @@ int cAppli_EditBlockInstr::Exe()
378387 mPhProj .DPBlockInstr ().SetDirOutInIfNotInit ();
379388 mPhProj .FinishInit ();
380389
381- cIrbCal_Block * aBlock = mFromScratch ?
382- new cIrbCal_Block :
383- mPhProj .ReadRigBoI (mNameBloc ,SVP::Yes) ;
390+ cIrbCal_Block * aBlock = mFromScratch ?
391+ new cIrbCal_Block :
392+ mPhProj .ReadRigBoI (mNameBloc ,SVP::Yes) ;
384393
394+ // if we add structure for camera
385395 if (IsInit (&mVPatsIm4Cam ))
386396 {
387397 std::string aPatSelOnDisk = mVPatsIm4Cam .at (0 );
388398 std::string aPatTimeStamp = GetDef (mVPatsIm4Cam ,1 ,aPatSelOnDisk);
389399 std::string aPatSelIm = GetDef (mVPatsIm4Cam ,2 ,aPatTimeStamp);
390400
391401 auto aVNameIm = ToVect (SetNameFromString (aPatSelOnDisk,true ));
402+ std::set<std::string> aSetNameCal;
392403 for (const auto & aNameIm : aVNameIm)
393404 {
394405 std::string aNameCal = mPhProj .StdNameCalibOfImage (aNameIm);
395- aBlock->SetCams ().AddCam (aNameCal,aPatTimeStamp,aPatSelIm,SVP::Yes);
406+ if (! BoolFind (aSetNameCal,aNameCal))
407+ {
408+ aSetNameCal.insert (aNameCal);
409+ aBlock->SetCams ().AddCam (aNameCal,aPatTimeStamp,aPatSelIm,SVP::Yes);
410+ }
396411 }
397412 }
413+
414+ // if we add the structure for clinometers
398415 if (mPhProj .DPMeasuresClino ().DirInIsInit ())
399416 {
400417 cSetMeasureClino aMesClin = mPhProj .ReadMeasureClino ();
@@ -404,7 +421,7 @@ int cAppli_EditBlockInstr::Exe()
404421 }
405422 }
406423
407-
424+ // save the result on disk
408425 mPhProj .SaveRigBoI (*aBlock);
409426
410427 delete aBlock;
0 commit comments