Skip to content

Commit 2319081

Browse files
author
deseilligny
committed
Add comments
1 parent 789622d commit 2319081

File tree

3 files changed

+57
-29
lines changed

3 files changed

+57
-29
lines changed

MMVII/include/MMVII_InstrumentalBlock.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ class cIrb_SigmaPoseRel
127127
{
128128
public :
129129
cIrb_SigmaPoseRel();
130-
cIrb_SigmaPoseRel(int aK1,int aK2,tREAL8 aSigmaTr,tREAL8 aSigmaRot);
131-
132-
int mK1;
133-
int mK2;
134-
tREAL8 mSigmaTr;
135-
tREAL8 mSigmaRot;
130+
cIrb_SigmaPoseRel(int aK1,int aK2,int aNb,tREAL8 aSigmaGlob,tREAL8 aSigmaTr,tREAL8 aSigmaRot);
131+
132+
int mK1; // index of image 1
133+
int mK2; // index of image 2
134+
int mNb; // number of pose relative
135+
tREAL8 mSigmaGlob; // sigma global mixing both
136+
tREAL8 mSigmaTr; // sigma on translation
137+
tREAL8 mSigmaRot; // sigla on rotation
136138
};
137139
void AddData(const cAuxAr2007 & anAux,cIrb_SigmaPoseRel & aSigmaPR);
138140

@@ -238,6 +240,8 @@ class cIrbComp_CamSet : public cMemCheck
238240

239241
/// pose of K2th relatively to K1th
240242
tPoseR PoseRel(size_t aK1,size_t aK2) const;
243+
244+
// A relative pose can be estimated iff both poses are init
241245
bool HasPoseRel(size_t aK1,size_t aK2) const;
242246

243247
private :
@@ -268,12 +272,16 @@ class cIrbComp_TimeS : public cMemCheck
268272
class cIrbComp_Block : public cMemCheck
269273
{
270274
public :
271-
275+
// "fundamuntal" constructor, creat from a calibration bloc
272276
cIrbComp_Block(const cIrbCal_Block &) ;
277+
// read calib from file with "absolute name" and call fundamuntal constructor
273278
cIrbComp_Block(const std::string & aNameFile);
279+
// read calib from name of block in standdar MMVI file and call fundamental constructot
274280
cIrbComp_Block(const cPhotogrammetricProject& ,const std::string & aNameBloc);
275281

282+
// Add an image if orientation exist (via PhProj)
276283
void AddImagePose(const std::string &,bool okImNotInBloc=false);
284+
// Add an image with given pose
277285
void AddImagePose(const tPoseR&,const std::string &,bool okImNotInBloc=false);
278286

279287

@@ -282,6 +290,7 @@ class cIrbComp_Block : public cMemCheck
282290
const cIrbCal_Block & CalBlock() const ; //< Accessor
283291
cIrbCal_Block & CalBlock() ; //< Accessor
284292

293+
// for a given pair K1/K2 the 'best' relative pose and its sigma
285294
std::pair<tPoseR,cIrb_SigmaPoseRel> ComputeCalibCamsInit(int aK1,int aK2) const;
286295
private :
287296
/// non copiable, too "dangerous"

MMVII/src/Instrumental/cInstrumentalBloc.cpp

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,28 @@ void cIrbComp_Block::AddImagePose(const std::string & aNameIm,bool okImNotInBlo
111111
std::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

337346
cAppli_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;

MMVII/src/Instrumental/cIrb_Cams.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,17 @@ void AddData(const cAuxAr2007 & anAux,cIrbCal_Cam1 & aCam)
134134
/* */
135135
/* *************************************************************** */
136136

137-
cIrb_SigmaPoseRel::cIrb_SigmaPoseRel(int aK1,int aK2,tREAL8 aSigmaTr,tREAL8 aSigmaRot) :
137+
cIrb_SigmaPoseRel::cIrb_SigmaPoseRel(int aK1,int aK2,int aNb,tREAL8 aSigmGlob,tREAL8 aSigmaTr,tREAL8 aSigmaRot) :
138138
mK1 (aK1),
139139
mK2 (aK2),
140+
mNb (aNb),
141+
mSigmaGlob (aSigmGlob),
140142
mSigmaTr (aSigmaTr),
141143
mSigmaRot (aSigmaRot)
142144
{
143145
}
144146
cIrb_SigmaPoseRel::cIrb_SigmaPoseRel() :
145-
cIrb_SigmaPoseRel(-1,-1,-1.0,-1.0)
147+
cIrb_SigmaPoseRel(-1,-1,-1,-1.0,-1.0,-1.0)
146148
{
147149
}
148150

0 commit comments

Comments
 (0)