Skip to content

Commit 8886215

Browse files
author
deseilligny
committed
Chg ori, in refactor Block Instr
1 parent 2319081 commit 8886215

12 files changed

+536
-267
lines changed

MMVII/include/MMVII_2Include_Serial_Tpl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ template <class Type,size_t aSz> void AddData(const cAuxAr2007 & anAux, cArray<
292292

293293
/** Serialization for map (will be) used for cSetMultipleTiePoints, and more ? */
294294

295-
template <class TypeKey,class TypeVal> void AddData(const cAuxAr2007 & anAux,std::map<TypeKey,TypeVal> & aMap)
295+
template <class TypeKey,class TypeVal> void StdMapAddData(const cAuxAr2007 & anAux,std::map<TypeKey,TypeVal> & aMap)
296296
{
297297
anAux.SetType(eTAAr::eMap);
298298
int aNb=aMap.size();
@@ -333,6 +333,11 @@ template <class TypeKey,class TypeVal> void AddData(const cAuxAr2007 & anAux,std
333333
}
334334
}
335335

336+
template <class TypeKey,class TypeVal> void AddData(const cAuxAr2007 & anAux,std::map<TypeKey,TypeVal> & aMap)
337+
{
338+
StdMapAddData(anAux,aMap);
339+
}
340+
336341

337342
template <class Type,const int Dim> void AddData(const cAuxAr2007 & anAux,cTplBox<Type,Dim> & aBox) { aBox.AddData(anAux); }
338343
template <class Type,const int Dim> void AddData(const cAuxAr2007 & anAux,cTplBoxOfPts<Type,Dim> & aBox) { aBox.AddData(anAux); }

MMVII/include/MMVII_AllClassDeclare.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ class cMMVII_Ofs;
9494
template <class Type> class cExtSet ;
9595
template <class Type> class cSelector ;
9696
template <class Type> class cDataSelector ;
97-
template <class Type> class cOrderedPair ;
97+
template <class Type> class cUnOrderedPair ;
9898

9999
typedef cSelector<std::string> tNameSelector;
100100
typedef cExtSet<std::string> tNameSet;
101-
typedef cOrderedPair<std::string> tNamePair; ///< Order does not matter
101+
typedef cUnOrderedPair<std::string> tNamePair; ///< Order does not matter
102102
typedef std::pair<std::string,std::string> tNameOCple; ///< Order matters
103103
typedef cExtSet<tNamePair> tNameRel;
104104

MMVII/include/MMVII_InstrumentalBlock.h

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class cIrbCal_Clino1; // one clino in a calib-bloc
4141
class cIrbCal_ClinoSet; // set of clino in a calib-bloc
4242
class cIrbCal_Block; // calib bloc of rigid instrument
4343

44-
class cIrb_SigmaPoseRel; // "helper" class for storing sigmas of rel poses
44+
class cIrb_SigmaInstr; // "helper" class for storing sigmas of rel poses
4545

4646

4747
class cIrbComp_Cam1; // one cam in a compute-bloc
@@ -123,20 +123,29 @@ class cIrbCal_Clino1 : public cMemCheck
123123
};
124124
void AddData(const cAuxAr2007 & anAux,cIrbCal_Clino1 & aClino);
125125

126-
class cIrb_SigmaPoseRel
126+
127+
class cIrb_SigmaInstr
127128
{
128-
public :
129-
cIrb_SigmaPoseRel();
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
129+
public :
130+
cIrb_SigmaInstr();
131+
cIrb_SigmaInstr(tREAL8 aW,tREAL8 aSigTr,tREAL8 aSigRot,tREAL8 aSigGlob);
132+
void AddNewSigma (const cIrb_SigmaInstr&,const tREAL8 & aWeigh=1.0);
133+
134+
void AddData(const cAuxAr2007 & anAux);
135+
136+
137+
tREAL8 SigmaTr() const;
138+
tREAL8 SigmaRot() const;
139+
tREAL8 SigmaGlob() const;
140+
141+
private :
142+
tREAL8 mSumW;
143+
tREAL8 mSumWTr;
144+
tREAL8 mSumWRot;
145+
tREAL8 mSumWGlob;
138146
};
139-
void AddData(const cAuxAr2007 & anAux,cIrb_SigmaPoseRel & aSigmaPR);
147+
void AddData(const cAuxAr2007 & anAux,cIrb_SigmaInstr & aClino);
148+
140149

141150

142151
/// class for representing the set of cameras embedded in a bloc
@@ -153,10 +162,10 @@ class cIrbCal_CamSet : public cMemCheck
153162

154163
size_t NbCams() const; //< Number of cameras
155164
int NumMaster() const; //< Accessor
165+
void SetNumMaster(int);
156166
cIrbCal_Cam1 & KthCam(size_t aK);
157167
const cIrbCal_Cam1 & KthCam(size_t aK) const;
158168
private :
159-
void SetSigma(const cIrb_SigmaPoseRel&) ; //< reset the camea
160169
void AddCam
161170
(
162171
const std::string & aNameCalib,
@@ -167,7 +176,6 @@ class cIrbCal_CamSet : public cMemCheck
167176

168177
int mNumMaster; //< num of "master" image
169178
std::vector<cIrbCal_Cam1> mVCams; //< set of cameras
170-
std::vector<cIrb_SigmaPoseRel> mVSigmas; //< sigmas of pairs
171179
};
172180
void AddData(const cAuxAr2007 & anAux,cIrbCal_CamSet & aCam);
173181

@@ -201,10 +209,16 @@ class cIrbCal_Block : public cMemCheck
201209
const cIrbCal_CamSet & SetCams() const ; //< Accessors
202210
cIrbCal_ClinoSet & SetClinos() ; //< Accessors
203211
const std::string & NameBloc() const; //< Accessor
212+
213+
void AddSigma(std::string aN1,std::string aN2, const cIrb_SigmaInstr &,const std::pair<tREAL8,tREAL8> & aWeight= {1.0,1.0} );
204214
private :
205-
std::string mNameBloc; //< Name of the bloc
206-
cIrbCal_CamSet mSetCams; //< Cameras used in the bloc
207-
cIrbCal_ClinoSet mSetClinos; //< Clinos used in the bloc
215+
std::string mNameBloc; //< Name of the bloc
216+
cIrbCal_CamSet mSetCams; //< Cameras used in the bloc
217+
cIrbCal_ClinoSet mSetClinos; //< Clinos used in the bloc
218+
219+
std::map<tNamePair,cIrb_SigmaInstr> mSigmaPair; //< Sigmas between pair of instr
220+
std::map<std::string,cIrb_SigmaInstr> mSigmaInd; //< Sigmas of each instrument
221+
208222
};
209223
void AddData(const cAuxAr2007 & anAux,cIrbCal_Block & aRBoI);
210224

@@ -272,6 +286,8 @@ class cIrbComp_TimeS : public cMemCheck
272286
class cIrbComp_Block : public cMemCheck
273287
{
274288
public :
289+
typedef std::pair<tPoseR,cIrb_SigmaInstr> tResCompCal;
290+
275291
// "fundamuntal" constructor, creat from a calibration bloc
276292
cIrbComp_Block(const cIrbCal_Block &) ;
277293
// read calib from file with "absolute name" and call fundamuntal constructor
@@ -291,7 +307,7 @@ class cIrbComp_Block : public cMemCheck
291307
cIrbCal_Block & CalBlock() ; //< Accessor
292308

293309
// for a given pair K1/K2 the 'best' relative pose and its sigma
294-
std::pair<tPoseR,cIrb_SigmaPoseRel> ComputeCalibCamsInit(int aK1,int aK2) const;
310+
tResCompCal ComputeCalibCamsInit(int aK1,int aK2) const;
295311
private :
296312
/// non copiable, too "dangerous"
297313
cIrbComp_Block(const cIrbComp_Block & ) = delete;

MMVII/include/MMVII_util_tpl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,25 @@ tNameRel RelNameFromXmlFileIfExist
208208

209209
/* ================================================ */
210210
/* */
211-
/* cOrderedPair */
211+
/* cUnOrderedPair */
212212
/* */
213213
/* ================================================ */
214214

215215
/// Pair where we want (a,b) == (b,a)
216216

217-
/** cOrderedPair are pretty match like pair<T,T> ,
217+
/** cUnOrderedPair are pretty match like pair<T,T> ,
218218
the main difference being that they modelise symetric graph.
219219
To assure that they are always in a single way, we
220220
force V1 <= V2
221221
*/
222-
template <class Type> class cOrderedPair
222+
template <class Type> class cUnOrderedPair
223223
{
224224
public :
225-
typedef cOrderedPair<Type> value;
226-
cOrderedPair(const Type & aV1,const Type & aV2); ///< Pair will be reordered
227-
cOrderedPair(); ///< Default constructor, notably for serializer
228-
bool operator < (const cOrderedPair<Type> & aP2) const;
229-
bool operator == (const cOrderedPair<Type> & aP2) const;
225+
typedef cUnOrderedPair<Type> value;
226+
cUnOrderedPair(const Type & aV1,const Type & aV2); ///< Pair will be reordered
227+
cUnOrderedPair(); ///< Default constructor, notably for serializer
228+
bool operator < (const cUnOrderedPair<Type> & aP2) const;
229+
bool operator == (const cUnOrderedPair<Type> & aP2) const;
230230
const Type & V1() const;
231231
const Type & V2() const;
232232
Type & V1() ;

MMVII/src/Exports/MMV2_MesIm_2_MMV1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int cAppli_MMV2_MesIm_2_MMV1::Exe()
6666
cSetMesGndPt aSetMes;
6767

6868
//load GCPs
69-
mPhProj.LoadGCP3D(aSetMes);
69+
// mPhProj.LoadGCP3D(aSetMes);
7070

7171
//load image measurements
7272
mPhProj.LoadIm(aSetMes,aCImage);
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#include "MMVII_InstrumentalBlock.h"
2+
3+
#include "cMMVII_Appli.h"
4+
#include "MMVII_2Include_Serial_Tpl.h"
5+
6+
7+
8+
9+
/**
10+
\file cInstrumentalBloc.cpp
11+
12+
13+
\brief This file contains the core implemantation of Block of rigid instrument
14+
15+
*/
16+
17+
namespace MMVII
18+
{
19+
20+
/* *************************************************************** */
21+
/* */
22+
/* cAppli_BlockInstrInitCam */
23+
/* */
24+
/* *************************************************************** */
25+
26+
class cAppli_BlockInstrInitCam : public cMMVII_Appli
27+
{
28+
public :
29+
30+
cAppli_BlockInstrInitCam(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli &);
31+
cCollecSpecArg2007 & ArgObl(cCollecSpecArg2007 & anArgObl) override;
32+
cCollecSpecArg2007 & ArgOpt(cCollecSpecArg2007 & anArgOpt) override;
33+
int Exe() override;
34+
// std::vector<std::string> Samples() const ;
35+
36+
private :
37+
cPhotogrammetricProject mPhProj;
38+
std::string mSpecImIn;
39+
cIrbComp_Block * mBlock;
40+
std::string mNameBloc;
41+
};
42+
43+
44+
cAppli_BlockInstrInitCam::cAppli_BlockInstrInitCam(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) :
45+
cMMVII_Appli (aVArgs,aSpec),
46+
mPhProj (*this),
47+
mBlock (nullptr),
48+
mNameBloc (cIrbCal_Block::theDefaultName)
49+
{
50+
}
51+
52+
cCollecSpecArg2007 & cAppli_BlockInstrInitCam::ArgObl(cCollecSpecArg2007 & anArgObl)
53+
{
54+
return anArgObl
55+
<< Arg2007(mSpecImIn,"Pattern/file for images", {{eTA2007::MPatFile,"0"},{eTA2007::FileDirProj}} )
56+
<< mPhProj.DPBlockInstr().ArgDirInMand()
57+
<< mPhProj.DPOrient().ArgDirInMand()
58+
<< mPhProj.DPBlockInstr().ArgDirOutMand()
59+
;
60+
}
61+
62+
cCollecSpecArg2007 & cAppli_BlockInstrInitCam::ArgOpt(cCollecSpecArg2007 & anArgOpt)
63+
{
64+
return anArgOpt
65+
<< AOpt2007(mNameBloc,"NameBloc","Name of bloc to calib ",{{eTA2007::HDV}})
66+
;
67+
}
68+
69+
int cAppli_BlockInstrInitCam::Exe()
70+
{
71+
mPhProj.FinishInit();
72+
// read an existing bloc from std folder
73+
mBlock = new cIrbComp_Block(mPhProj,mNameBloc);
74+
size_t aNbCam = mBlock->NbCams();
75+
76+
// add all the camera
77+
for (const auto & aNameIm : VectMainSet(0))
78+
{
79+
mBlock->AddImagePose(aNameIm);
80+
}
81+
82+
// initialize the sigma of each pair of cams & compute the score of each cam
83+
std::vector<tREAL8> aVScoreCam(aNbCam,0.0); // Cumultated score
84+
for (size_t aKC1=0 ; aKC1<aNbCam ; aKC1++)
85+
{
86+
for (size_t aKC2=0 ; aKC2<mBlock->NbCams(); aKC2++)
87+
{
88+
if (aKC1!=aKC2)
89+
{
90+
const auto & aPair = mBlock->ComputeCalibCamsInit(aKC1,aKC2); // Pose + sigma
91+
aVScoreCam.at(aKC1) += aPair.second.SigmaGlob();
92+
aVScoreCam.at(aKC2) += aPair.second.SigmaGlob();
93+
mBlock->CalBlock().AddSigma
94+
(
95+
mBlock->CalBlock().SetCams().KthCam(aKC1).NameCal(),
96+
mBlock->CalBlock().SetCams().KthCam(aKC2).NameCal(),
97+
aPair.second
98+
);
99+
}
100+
}
101+
}
102+
103+
// compute num of master
104+
cWhichMin<size_t,tREAL8> aMinK;
105+
for (size_t aKC1 = 0 ; aKC1<aNbCam ; aKC1++)
106+
aMinK.Add(aKC1,aVScoreCam.at(aKC1));
107+
int aNumMaster = aMinK.IndexExtre();
108+
109+
mBlock->CalBlock().SetCams().SetNumMaster(aNumMaster);
110+
StdOut() << " NUM-MASTER " << aNumMaster << "\n";
111+
112+
// initialise the relative pose in the ARBITRARY coord syst of master cam
113+
for (size_t aKC1=0 ; aKC1<aNbCam ; aKC1++)
114+
{
115+
const auto & [aPose,aSigma] = mBlock->ComputeCalibCamsInit(aNumMaster,aKC1);
116+
mBlock->CalBlock().SetCams().KthCam(aKC1).SetPose(aPose);
117+
}
118+
119+
mPhProj.SaveRigBoI(mBlock->CalBlock());
120+
delete mBlock;
121+
122+
return EXIT_SUCCESS;
123+
}
124+
125+
/* ==================================================== */
126+
/* */
127+
/* MMVII */
128+
/* */
129+
/* ==================================================== */
130+
131+
132+
tMMVII_UnikPApli Alloc_BlockInstrInitCam(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec)
133+
{
134+
return tMMVII_UnikPApli(new cAppli_BlockInstrInitCam(aVArgs,aSpec));
135+
}
136+
137+
cSpecMMVII_Appli TheSpec_BlockInstrInitCam
138+
(
139+
"BlockInstrInitCam",
140+
Alloc_BlockInstrInitCam,
141+
"Init camera poses inside a block of instrument",
142+
{eApF::BlockInstr,eApF::Ori},
143+
{eApDT::BlockInstr,eApDT::Ori},
144+
{eApDT::BlockInstr},
145+
__FILE__
146+
);
147+
148+
149+
};
150+

0 commit comments

Comments
 (0)