Skip to content

Commit b97d84d

Browse files
author
deseilligny
committed
Ok (?) wire compensation (to bench later)
1 parent ad082a3 commit b97d84d

File tree

7 files changed

+147
-50
lines changed

7 files changed

+147
-50
lines changed

MMVII/include/MMVII_InstrumentalBlock.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,26 @@ class cIrbCal_Cam1 : public cMemCheck
8181
cIrbCal_Cam1(); //< required for serialisation
8282
/// "real" constructor
8383
cIrbCal_Cam1(int aNum,const std::string & aNameCal,const std::string & aTimeStamp,const std::string & aPatImSel);
84-
const std::string & NameCal() const; //< Accessor
84+
const std::string & NameCal() const; //< Accessor
8585
int Num() const; //< Accesor
86-
void AddData(const cAuxAr2007 & anAux); //< Serializer
86+
void AddData(const cAuxAr2007 & anAux); //< Serializer
8787

8888
/// Compute the time stamp identifier associated to a name of image
8989
std::string TimeStamp(const std::string & aNameImage ) const;
9090

9191
/// Indicate if the image belongs to the block
9292
bool ImageIsInBlock (const std::string & ) const;
93-
/// modify the pose
94-
void SetPose(const tPoseR & aPose);
93+
94+
/** modify the pose, separate from constructor because must be done in calib init, after block creation */
95+
void SetPose(const tPoseR & aPose);
9596

9697
private :
9798
int mNum;
9899
std::string mNameCal; ///< "full" name of calibration associated to, like "CalibIntr_CamNIKON_D5600_Add043_Foc24000"
99100
std::string mPatTimeStamp; //< use to extract time stamp from a name
100101
bool mSelIsPat; ///< indicate if selector is pattern/file
101-
std::string mImSelect; ///< selector, indicate if an image belongs to the block
102-
bool mIsInit; ///< was the pose in the block computed ?
102+
std::string mImSelect; ///< selector, indicate if an image belongs to the block
103+
bool mIsInit; ///< was the pose in the block computed ?
103104
tPoseR mPoseInBlock; ///< Position in the block +- boresight
104105
};
105106
/// public interface to serialization
@@ -145,15 +146,15 @@ class cIrbCal_CamSet : public cMemCheck
145146

146147
cIrbCal_CamSet(); //< constructor, ok for serial
147148

148-
void AddData(const cAuxAr2007 & anAux); //< serialization
149+
void AddData(const cAuxAr2007 & anAux); //< serialization
149150
cIrbCal_Cam1 * CamFromNameCalib(const std::string& aName,bool SVP=false);
150151

151152
size_t NbCams() const; //< Number of cameras
152153
int NumMaster() const; //< Accessor
153154
cIrbCal_Cam1 & KthCam(size_t aK);
154155
const cIrbCal_Cam1 & KthCam(size_t aK) const;
155156
private :
156-
void SetSigma(const cIrb_SigmaPoseRel&) ; //< reset the camea
157+
void SetSigma(const cIrb_SigmaPoseRel&) ; //< reset the camea
157158
void AddCam
158159
(
159160
const std::string & aNameCalib,
@@ -163,8 +164,8 @@ class cIrbCal_CamSet : public cMemCheck
163164
);
164165

165166
int mNumMaster; //< num of "master" image
166-
std::vector<cIrbCal_Cam1> mVCams; //< set of cameras
167-
std::vector<cIrb_SigmaPoseRel> mVSigmas; //< sigmas of pairs
167+
std::vector<cIrbCal_Cam1> mVCams; //< set of cameras
168+
std::vector<cIrb_SigmaPoseRel> mVSigmas; //< sigmas of pairs
168169
};
169170
void AddData(const cAuxAr2007 & anAux,cIrbCal_CamSet & aCam);
170171

@@ -175,7 +176,7 @@ class cIrbCal_ClinoSet : public cMemCheck
175176
friend cAppli_EditBlockInstr;
176177

177178
cIrbCal_ClinoSet();
178-
void AddData(const cAuxAr2007 & anAux);
179+
void AddData(const cAuxAr2007 & anAux);
179180
private :
180181
cIrbCal_Clino1 * ClinoFromName(const std::string& aName);
181182
void AddClino(const std::string &,bool SVP=false);
@@ -190,17 +191,17 @@ class cIrbCal_Block : public cMemCheck
190191
public :
191192
friend cIrbComp_Block;
192193

193-
static const std::string theDefaultName; /// in most application there is only one block
194+
static const std::string theDefaultName; /// in most application there is only one block
194195
cIrbCal_Block(const std::string& aName=theDefaultName);
195-
void AddData(const cAuxAr2007 & anAux);
196+
void AddData(const cAuxAr2007 & anAux);
196197

197-
cIrbCal_CamSet & SetCams() ; //< Accessors
198-
const cIrbCal_CamSet & SetCams() const ; //< Accessors
199-
cIrbCal_ClinoSet & SetClinos() ; //< Accessors
200-
const std::string & NameBloc() const; //< Accessor
198+
cIrbCal_CamSet & SetCams() ; //< Accessors
199+
const cIrbCal_CamSet & SetCams() const ; //< Accessors
200+
cIrbCal_ClinoSet & SetClinos() ; //< Accessors
201+
const std::string & NameBloc() const; //< Accessor
201202
private :
202-
std::string mNameBloc; //< Name of the bloc
203-
cIrbCal_CamSet mSetCams; //< Cameras used in the bloc
203+
std::string mNameBloc; //< Name of the bloc
204+
cIrbCal_CamSet mSetCams; //< Cameras used in the bloc
204205
cIrbCal_ClinoSet mSetClinos; //< Clinos used in the bloc
205206
};
206207
void AddData(const cAuxAr2007 & anAux,cIrbCal_Block & aRBoI);

MMVII/include/MMVII_MeasuresIm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ class cOneLineAntiParal
545545
public :
546546
cOneLineAntiParal();
547547

548+
std::string NameLine() const; // return "" if optional not init
549+
548550
std::string mNameIm;
551+
std::optional<std::string> mNameLine;
549552
tSeg2dr mSeg;
550553
tREAL8 mAngDif;
551554
tREAL8 mWidth;

MMVII/src/BundleAdjustment/BundleAdjustment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ class cMMVII_BundleAdj
563563
std::vector<std::string> mParam_UC_UK;
564564
std::vector<int> mIndCompUC;
565565
cResult_UC_SUR<tREAL8>* mRUCSUR;
566-
cUK_Line3D_4BA* mLineAdjust;
566+
std::vector<cUK_Line3D_4BA*> mVecLineAdjust;
567567
};
568568

569569

MMVII/src/BundleAdjustment/BundleLines.cpp

Lines changed: 114 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,46 @@ namespace MMVII
66
{
77

88

9+
class cMerged_MultipleLines
10+
{
11+
public :
12+
typedef std::vector<cOneLineAntiParal> tContLAP;
13+
typedef std::map<std::string,tContLAP> tMapOf1L;
14+
15+
void AddLAP(const cLinesAntiParal1Im &);
16+
const std::map<std::string,tMapOf1L>& LinesAP() const ;
17+
18+
private :
19+
20+
// mMapL[NameLine][NameIm]
21+
std::map<std::string,tMapOf1L> mLinesAP;
22+
std::map<std::string,std::string> mNamesCalib;
23+
};
24+
25+
void cMerged_MultipleLines::AddLAP(const cLinesAntiParal1Im & aSetLAP)
26+
{
27+
// Check coherence in calibration folders
28+
{
29+
std::string & aNameCal = mNamesCalib[aSetLAP.mNameIm];
30+
if (aNameCal=="")
31+
{
32+
aNameCal = aSetLAP.mDirCalib;
33+
}
34+
else
35+
{
36+
MMVII_INTERNAL_ASSERT_always(aNameCal == aSetLAP.mDirCalib,"Multiple Caliv in cMerged_MultipleLines");
37+
}
38+
}
939

40+
//
41+
for (const auto & aLAP : aSetLAP.mLines )
42+
{
43+
mLinesAP[aLAP.NameLine()][aLAP.mNameIm].push_back(aLAP); //std::string aNameLine;
44+
}
45+
}
46+
47+
const std::map<std::string,typename cMerged_MultipleLines::tMapOf1L>&
48+
cMerged_MultipleLines::LinesAP() const {return mLinesAP;}
1049

1150

1251
/** Store data one line 2d->3d, essentially data */
@@ -41,7 +80,8 @@ class cOneData_L23 : public cMemCheck
4180
class cCam2_Line_2Dto3D : public cMemCheck
4281
{
4382
public :
44-
cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject *);
83+
84+
static std::vector<cCam2_Line_2Dto3D*> AllocV(const std::vector<cSensorCamPC *> &,const cPhotogrammetricProject &);
4585

4686
const tSegComp3dr & Seg3d () const; //< Accessor
4787
const std::string & NameLine() const; //< Accessor
@@ -51,6 +91,9 @@ class cCam2_Line_2Dto3D : public cMemCheck
5191
cPt3dr PtOfWeight(const tREAL8 aWeight);
5292

5393
private :
94+
cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,const std::string & aNameLine,const cMerged_MultipleLines::tMapOf1L & );
95+
96+
5497
cCam2_Line_2Dto3D(const cCam2_Line_2Dto3D&) = delete;
5598
void AssertSeg3dIsInit() const;
5699

@@ -68,7 +111,7 @@ class cUK_Line3D_4BA : public cObjWithUnkowns<tREAL8>
68111
public :
69112
friend cMMVII_BundleAdj;
70113
//< constructor,
71-
cUK_Line3D_4BA(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject *,cMMVII_BundleAdj *,tREAL8 aSigmaIm,int aNbPts);
114+
cUK_Line3D_4BA(cCam2_Line_2Dto3D *,cMMVII_BundleAdj *,tREAL8 aSigmaIm,int aNbPts);
72115
~cUK_Line3D_4BA();
73116

74117
void AddEquation();
@@ -151,22 +194,30 @@ cWeightAv<tREAL8,tREAL8> & cOneData_L23::AvgResidual()
151194
/* */
152195
/* *********************************************************** */
153196

154-
cCam2_Line_2Dto3D::cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject * aPhProj) :
197+
198+
cCam2_Line_2Dto3D::cCam2_Line_2Dto3D
199+
(
200+
const std::vector<cSensorCamPC *> & aVCam,
201+
const std::string & aNameLine,
202+
const cMerged_MultipleLines::tMapOf1L & aMapOf1L
203+
) :
155204
mSeg3d (cPt3dr(0,0,0),cPt3dr(1,1,1)),
156-
mSeg3dIsInit (false)
205+
mSeg3dIsInit (false),
206+
mNameLine (aNameLine)
157207
{
158208
std::vector<cPlane3D> aVPlaneOk;
159209

160210
for (size_t aKCam=0 ; aKCam<aVCam.size() ; aKCam++)
161211
{
162212
const auto & aCam = aVCam.at(aKCam);
163-
if (aCam != nullptr)
164-
{
213+
if (aCam != nullptr)
214+
{
165215
const std::string & aNameIm = aCam->NameImage();
166-
if (aPhProj->HasFileLines(aNameIm))
216+
const auto & anIter = aMapOf1L.find(aNameIm);
217+
218+
if (anIter != aMapOf1L.end())
167219
{
168-
cLinesAntiParal1Im aSetL = aPhProj->ReadLines(aNameIm);
169-
const std::vector<cOneLineAntiParal> & aVL = aSetL.mLines;
220+
const cMerged_MultipleLines::tContLAP & aVL = anIter->second;
170221

171222
// At this step we dont handle multiple lines
172223
if (aVL.size()==1)
@@ -183,7 +234,6 @@ cCam2_Line_2Dto3D::cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,c
183234
mSeg3dIsInit = true;
184235
mSeg3d = tSegComp3dr (cPlane3D::InterPlane(aVPlaneOk));
185236
cBoundVals<tREAL8> aIntervAbsc;
186-
mNameLine = aPhProj-> DPGndPt2D().DirIn();
187237

188238
for (auto & aData : mDatas_L23)
189239
{
@@ -206,6 +256,27 @@ cCam2_Line_2Dto3D::cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,c
206256

207257
}
208258

259+
std::vector<cCam2_Line_2Dto3D*> cCam2_Line_2Dto3D::AllocV(const std::vector<cSensorCamPC *> & aVCam,const cPhotogrammetricProject & aPhProj)
260+
{
261+
std::vector<cCam2_Line_2Dto3D*> aResult;
262+
263+
cMerged_MultipleLines aMML;
264+
265+
for (const auto & aCam : aVCam)
266+
{
267+
cLinesAntiParal1Im aLAP = aPhProj.ReadLines(aCam->NameImage());
268+
aMML.AddLAP(aLAP);
269+
}
270+
271+
for (const auto & [aNameLine,aMapOf1L]: aMML.LinesAP())
272+
{
273+
aResult.push_back(new cCam2_Line_2Dto3D(aVCam,aNameLine,aMapOf1L));
274+
}
275+
276+
return aResult;
277+
}
278+
279+
209280
void cCam2_Line_2Dto3D::AssertSeg3dIsInit() const
210281
{
211282
MMVII_INTERNAL_ASSERT_always(mSeg3dIsInit,"cCam2_Line_2Dto3D::AssertSeg3dIsInit");
@@ -242,28 +313,21 @@ std::vector<cOneData_L23> & cCam2_Line_2Dto3D::Datas_L23()
242313
// mUkN1 (cPt2dr(0,0),std::string("Line3d_Uk1") + mLineInit->NameLine()),
243314
cUK_Line3D_4BA::cUK_Line3D_4BA
244315
(
245-
const std::vector<cSensorCamPC *> & aVCam,
246-
cPhotogrammetricProject * aPhProj,
316+
cCam2_Line_2Dto3D * aLine,
247317
cMMVII_BundleAdj * aBA,
248318
tREAL8 aSigmaIm,
249319
int aNbPts
250320
) :
251321
mBA (aBA),
252-
mLineInit (new cCam2_Line_2Dto3D (aVCam,aPhProj)),
322+
mLineInit (aLine),
253323
mSeg (mLineInit->Seg3d()),
254324
mUkN1 (0.0,0.0),
255325
mUkN2 (0.0,0.0) ,
256326
mSigmaIm (aSigmaIm),
257327
mNbPtSampling (aNbPts)
258328
{
259-
// ddOneObj()
260-
261-
// aBA->SetIntervUK().AddOneObj(&mUkN1);
262-
// aBA->SetIntervUK().AddOneObj(&mUkN2);
263-
264329
InitNormals();
265-
for (auto aCam : aVCam)
266-
aCam->InternalCalib()->SetAndGet_EqProjSeg();
330+
267331
}
268332

269333
cUK_Line3D_4BA::~cUK_Line3D_4BA()
@@ -332,17 +396,22 @@ void cUK_Line3D_4BA::AddOneEquation(tREAL8 aLambda,tREAL8 aWeight,cOneData_L23&
332396
cPt2dr aNormL2 = Rot90(aTgtL2);
333397

334398
tREAL8 aResidual= Norm2(aPImPG-aPImOnL2);
399+
/*
335400
{
336401
auto aCalib = aData.mCam->InternalCalib();
337402
const tSeg2dr aSegD = aData.mSeg;
338403
339404
tSegComp2dr aSeg_UD (aCalib->Undist(aSegD.P1()),aCalib->Undist(aSegD.P2()));
340405
cPt2dr aP_UD = aCalib->Undist(aPImPG);
341406
342-
StdOut() << "** RRRR " << aResidual << " DD=" << aSeg_UD.Dist(aP_UD) << "\n";
407+
cPt2dr aP_UD2 = aCalib->Undist(aPImOnL2);
408+
409+
410+
StdOut() << "** RRRR " << aResidual << " DD=" << aSeg_UD.Dist(aP_UD) << " D2=" << aSeg_UD.Dist(aP_UD2) << "\n";
343411
344412
//const tSeg2dr mSeg
345413
}
414+
*/
346415
aData.AvgResidual().Add(1.0,aResidual);
347416
//StdOut() << " PIMG=" << aPImPG << " PL=" << aPImOnL2 << "\n";
348417

@@ -397,6 +466,14 @@ void cUK_Line3D_4BA::AddEquation()
397466
for ( auto & aData_L23 : mLineInit->Datas_L23())
398467
AddOneEquation(aLambda,aWeight,aData_L23);
399468
}
469+
470+
StdOut() << " LineResidual ";
471+
for ( auto & aData_L23 : mLineInit->Datas_L23())
472+
{
473+
StdOut() << " " << aData_L23.AvgResidual().Average();
474+
}
475+
StdOut() << "\n";
476+
400477
}
401478

402479
/* *********************************************************** */
@@ -407,25 +484,34 @@ void cUK_Line3D_4BA::AddEquation()
407484

408485
void cMMVII_BundleAdj::AddLineAdjust(const std::vector<std::string> & aVParam)
409486
{
410-
tREAL8 aSigmaIm = cStrIO<double>::FromStr(aVParam.at(0));
411-
int aNbPts = cStrIO<int>::FromStr(aVParam.at(1));
487+
for (auto aCam : mVSCPC)
488+
aCam->InternalCalib()->SetAndGet_EqProjSeg();
489+
490+
tREAL8 aSigmaIm = cStrIO<double>::FromStr(aVParam.at(0));
491+
int aNbPts = cStrIO<int>::FromStr(aVParam.at(1));
412492

413-
mLineAdjust = new cUK_Line3D_4BA(mVSCPC,mPhProj,this,aSigmaIm,aNbPts);
414-
mSetIntervUK.AddOneObj(mLineAdjust);
493+
std::vector<cCam2_Line_2Dto3D*> aVecL = cCam2_Line_2Dto3D::AllocV(mVSCPC,*mPhProj);
494+
495+
for (const auto & aPtrL : aVecL)
496+
{
497+
mVecLineAdjust.push_back( new cUK_Line3D_4BA(aPtrL,this,aSigmaIm,aNbPts));
498+
mSetIntervUK.AddOneObj(mVecLineAdjust.back());
499+
}
415500
}
416501

417502
void cMMVII_BundleAdj::IterAdjustOnLine()
418503
{
419-
if (mLineAdjust)
420-
mLineAdjust->AddEquation();
504+
for (auto aPtrL : mVecLineAdjust)
505+
aPtrL->AddEquation();
421506
}
422507

423508

424509
// cUK_Line3D_4BA::cUK_Line3D_4BA(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject * aPhProj,cMMVII_BundleAdj * aBA) :
425510

426511
void cMMVII_BundleAdj::DeleteLineAdjust()
427512
{
428-
delete mLineAdjust;
513+
DeleteAllAndClear(mVecLineAdjust);
514+
//delete mLineAdjust;
429515
}
430516

431517

MMVII/src/BundleAdjustment/cMMVII_BundleAdj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ cMMVII_BundleAdj::cMMVII_BundleAdj(cPhotogrammetricProject * aPhp) :
105105
mVerbose (true),
106106
mShow_UC_UK (false),
107107
mRUCSUR (nullptr),
108-
mLineAdjust (nullptr)
108+
mVecLineAdjust ()
109109
{
110110
}
111111

MMVII/src/OrientReport/BlocReport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ cCollecSpecArg2007 & cAppli_ReportBlock::ArgOpt(cCollecSpecArg2007 & anArgOpt)
223223
<< AOpt2007(mDirExReport,"DirExRep","Fix globally Directory of Report Name")
224224
<< AOpt2007(mPercStat,"PercStat","Percentils for stat in global report",{{eTA2007::HDV}})
225225

226-
<< AOpt2007(mExtCernStat,"ExtCernStat","Do statistic specific to Cerns Wire distance")
226+
<< AOpt2007(mExtCernStat,"ExtCernStat","If set : do statistic specific to Cerns Wire distance and fix CSV file")
227227
<< AOpt2007(mCernAllPoint,"DoCernAllPt","For cern, compute Wire distance for all points",{{eTA2007::HDV}})
228228
<< mPhProj.DPGndPt3D().ArgDirInOpt("","GCP 3D coordinate for computing centre")
229229
<< AOpt2007(mSphereCenter,"SphereC","Additionnal GPC to export",{{eTA2007::HDV}})

0 commit comments

Comments
 (0)