Skip to content

Commit 344696c

Browse files
author
deseilligny
committed
Back Up
1 parent fada7af commit 344696c

File tree

3 files changed

+127
-52
lines changed

3 files changed

+127
-52
lines changed

MMVII/src/BundleAdjustment/BundleAdjustment.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class cBA_GCP;
2020
class cBA_Clino;
2121
class cBA_BlocRig;
2222

23+
class cUK_Line3D_4BA;
2324

2425
/** "Standard" weighting classes, used the following formula
2526
*
@@ -427,7 +428,8 @@ class cMMVII_BundleAdj
427428
void AddGCP2D(cMes2DDirInfo * aMesDirInfo, cSetMesPtOf1Im & aSetMesIm, cSensorImage* aSens, eLevelCheck aOnNonExistGCP=eLevelCheck::Warning, bool verbose=true);
428429
cBA_GCP& getGCP() { return mGCP;}
429430

430-
/// ============ Add Lidar/Photogra ===============
431+
/// ============ Add Lidar/Photogra =============== void AddLineAdjust(const std::vector<std::string> &);
432+
431433
void Add1AdjLidarPhotogra(const std::vector<std::string> &);
432434

433435
/// ============ Add multiple tie point ============
@@ -457,6 +459,8 @@ class cMMVII_BundleAdj
457459
void AddConstrainteRefPose(cSensorCamPC & aCam,cSensorCamPC & aCamRef);
458460

459461

462+
void AddLineAdjust(const std::vector<std::string> &);
463+
460464
void SaveBlocRigid();
461465
void Save_newGCP3D();
462466
void SaveTopo();
@@ -471,7 +475,9 @@ class cMMVII_BundleAdj
471475

472476
cResolSysNonLinear<tREAL8> * Sys(); /// Real object, will disapear when fully interfaced for mSys
473477

478+
cSetInterUK_MultipeObj<tREAL8> & SetIntervUK();
474479
private :
480+
void DeleteLineAdjust();
475481

476482
//============== Methods =============================
477483
cMMVII_BundleAdj(const cMMVII_BundleAdj &) = delete;
@@ -556,6 +562,7 @@ class cMMVII_BundleAdj
556562
std::vector<std::string> mParam_UC_UK;
557563
std::vector<int> mIndCompUC;
558564
cResult_UC_SUR<tREAL8>* mRUCSUR;
565+
cUK_Line3D_4BA* mLineAdjust;
559566
};
560567

561568

MMVII/src/BundleAdjustment/BundleLines.cpp

Lines changed: 115 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
namespace MMVII
66
{
77

8-
class cOneData_L23; //< Store data one line 2d->3d
9-
class cCam2_Line_2Dto3D; //< Compute initial "known" 3d line from 2d obs in camera
10-
class cUK_Line3D_4BA ; //< Adjust unknown 3d line
8+
119

1210

1311

1412
/** Store data one line 2d->3d, essentially data */
1513

16-
class cOneData_L23
14+
class cOneData_L23 : public cMemCheck
1715
{
1816
public :
1917
/// constructor
@@ -38,17 +36,18 @@ class cOneData_L23
3836

3937

4038
/// class to handle computation
41-
class cCam2_Line_2Dto3D
39+
class cCam2_Line_2Dto3D : public cMemCheck
4240
{
4341
public :
4442
cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject *);
4543

46-
const tSegComp3dr & Seg3d () const;
47-
const std::string & NameLine() const;
48-
std::vector<cOneData_L23> Datas_L23();
44+
const tSegComp3dr & Seg3d () const; //< Accessor
45+
const std::string & NameLine() const; //< Accessor
46+
const std::vector<cOneData_L23> & Datas_L23() const; //< Accessor
4947
cPt3dr PtOfWeight(const tREAL8 aWeight);
5048

5149
private :
50+
cCam2_Line_2Dto3D(const cCam2_Line_2Dto3D&) = delete;
5251
void AssertSeg3dIsInit() const;
5352

5453
tSegComp3dr mSeg3d;
@@ -59,35 +58,38 @@ class cCam2_Line_2Dto3D
5958
};
6059

6160

62-
63-
/** in cUK_Line3D_4BA with put data in a specific class to allow copy (in "OnUpdate"),
64-
* which would be forbiden due to inheritance */
65-
66-
6761
/// class handling a 3D unknown line for bundle adjusment
6862
class cUK_Line3D_4BA : public cObjWithUnkowns<tREAL8>
6963
{
7064
public :
65+
friend cMMVII_BundleAdj;
7166
//< constructor,
72-
cUK_Line3D_4BA(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject *,cMMVII_BundleAdj *);
67+
cUK_Line3D_4BA(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject *,cMMVII_BundleAdj *,tREAL8 aSigmaIm,int aNbPts);
68+
~cUK_Line3D_4BA();
7369

74-
void AddEquation(tREAL8 aSigmaLine,int aNbSampling);
70+
void AddEquation();
7571
private :
72+
73+
74+
cUK_Line3D_4BA(const cUK_Line3D_4BA &) = delete;
7675
void AddOneEquation(tREAL8 aLambda, tREAL8 aWeight,const cOneData_L23&);
7776
void InitNormals();
7877

7978
/// "reaction" after linear update
80-
void OnUpdate() override;
79+
void OnUpdate() override;
8180
/// method called when the object must indicate its unknowns
8281
void PutUknowsInSetInterval() override;
82+
void FillGetAdrInfoParam(cGetAdrInfoParam<tREAL8> &) override;
8383

8484
cMMVII_BundleAdj* mBA;
85-
cCam2_Line_2Dto3D mLineInit;
85+
cCam2_Line_2Dto3D * mLineInit;
8686
tSegComp3dr mSeg;
8787
cPt3dr mNorm_x; //< the first vector normal
8888
cPt3dr mNorm_y; //< the second vector normal
89-
cPt2dr_UK mUkN1; //< unknown displacement at Seg.P1, coded as "Uk1.x Nx+ Uk1.y Ny"
90-
cPt2dr_UK mUkN2; //< unknown displacement at Seg.P2
89+
cPt2dr mUkN1; //< unknown displacement at Seg.P1, coded as "Uk1.x Nx+ Uk1.y Ny"
90+
cPt2dr mUkN2; //< unknown displacement at Seg.P2
91+
tREAL8 mSigmaIm;
92+
int mNbPtSampling;
9193
//cUK_Line3D_4BA_Data mData;
9294
};
9395

@@ -107,6 +109,10 @@ cOneData_L23::cOneData_L23(cSensorCamPC * aCam,const tSeg2dr & aSeg,int aKIm) :
107109
mLineM (nullptr)
108110
{
109111
}
112+
113+
114+
115+
110116
cOneData_L23::~cOneData_L23()
111117
{
112118
delete mLineM;
@@ -143,18 +149,21 @@ cCam2_Line_2Dto3D::cCam2_Line_2Dto3D(const std::vector<cSensorCamPC *> & aVCam,c
143149
for (size_t aKCam=0 ; aKCam<aVCam.size() ; aKCam++)
144150
{
145151
const auto & aCam = aVCam.at(aKCam);
146-
const std::string & aNameIm = aCam->NameImage();
147-
if (aPhProj->HasFileLines(aNameIm))
148-
{
149-
cLinesAntiParal1Im aSetL = aPhProj->ReadLines(aNameIm);
150-
const std::vector<cOneLineAntiParal> & aVL = aSetL.mLines;
151-
152-
// At this step we dont handle multiple lines
153-
if (aVL.size()==1)
154-
{
155-
mDatas_L23.push_back(cOneData_L23(aCam,aVL.at(0).mSeg,aKCam));
156-
aVPlaneOk.push_back(mDatas_L23.back().mPlane);
157-
}
152+
if (aCam != nullptr)
153+
{
154+
const std::string & aNameIm = aCam->NameImage();
155+
if (aPhProj->HasFileLines(aNameIm))
156+
{
157+
cLinesAntiParal1Im aSetL = aPhProj->ReadLines(aNameIm);
158+
const std::vector<cOneLineAntiParal> & aVL = aSetL.mLines;
159+
160+
// At this step we dont handle multiple lines
161+
if (aVL.size()==1)
162+
{
163+
mDatas_L23.push_back(cOneData_L23(aCam,aVL.at(0).mSeg,aKCam));
164+
aVPlaneOk.push_back(mDatas_L23.back().mPlane);
165+
}
166+
}
158167
}
159168
}
160169

@@ -205,25 +214,49 @@ const std::string & cCam2_Line_2Dto3D::NameLine() const
205214
}
206215

207216

217+
const std::vector<cOneData_L23> & cCam2_Line_2Dto3D::Datas_L23() const
218+
{
219+
return mDatas_L23;
220+
}
208221

209222
/* *********************************************************** */
210223
/* */
211224
/* cUK_Line3D_4BA */
212225
/* */
213226
/* *********************************************************** */
214227

215-
cUK_Line3D_4BA::cUK_Line3D_4BA(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject * aPhProj,cMMVII_BundleAdj * aBA) :
216-
mBA (aBA),
217-
mLineInit (aVCam,aPhProj),
218-
mSeg (mLineInit.Seg3d()),
219-
mUkN1 (cPt2dr(0,0),std::string("Line3d_Uk1") + mLineInit.NameLine()),
220-
mUkN2 (cPt2dr(0,0),std::string("Line3d_Uk2") + mLineInit.NameLine())
228+
// mUkN1 (cPt2dr(0,0),std::string("Line3d_Uk1") + mLineInit->NameLine()),
229+
cUK_Line3D_4BA::cUK_Line3D_4BA
230+
(
231+
const std::vector<cSensorCamPC *> & aVCam,
232+
cPhotogrammetricProject * aPhProj,
233+
cMMVII_BundleAdj * aBA,
234+
tREAL8 aSigmaIm,
235+
int aNbPts
236+
) :
237+
mBA (aBA),
238+
mLineInit (new cCam2_Line_2Dto3D (aVCam,aPhProj)),
239+
mSeg (mLineInit->Seg3d()),
240+
mUkN1 (0.0,0.0),
241+
mUkN2 (0.0,0.0) ,
242+
mSigmaIm (aSigmaIm),
243+
mNbPtSampling (aNbPts)
221244
{
245+
// ddOneObj()
246+
247+
// aBA->SetIntervUK().AddOneObj(&mUkN1);
248+
// aBA->SetIntervUK().AddOneObj(&mUkN2);
249+
222250
InitNormals();
223251
for (auto aCam : aVCam)
224252
aCam->InternalCalib()->SetAndGet_EqProjSeg();
225253
}
226254

255+
cUK_Line3D_4BA::~cUK_Line3D_4BA()
256+
{
257+
delete mLineInit;
258+
}
259+
227260
void cUK_Line3D_4BA::InitNormals()
228261
{
229262
tRotR aRot = tRotR::CompleteRON(mSeg.Tgt());
@@ -233,20 +266,32 @@ void cUK_Line3D_4BA::InitNormals()
233266

234267
void cUK_Line3D_4BA::PutUknowsInSetInterval()
235268
{
236-
mSetInterv->AddOneInterv(mUkN1.Pt());
237-
mSetInterv->AddOneInterv(mUkN2.Pt());
269+
mSetInterv->AddOneInterv(mUkN1);
270+
mSetInterv->AddOneInterv(mUkN2);
271+
}
272+
273+
void cUK_Line3D_4BA::FillGetAdrInfoParam(cGetAdrInfoParam<tREAL8> & aGAIP)
274+
{
275+
aGAIP.TestParam(this, &(mUkN1.x()),"x1");
276+
aGAIP.TestParam(this, &(mUkN1.y()),"y1");
277+
aGAIP.TestParam(this, &(mUkN2.x()),"x2");
278+
aGAIP.TestParam(this, &(mUkN2.y()),"y2");
279+
280+
aGAIP.SetNameType("Line3D");
281+
aGAIP.SetIdObj(mLineInit->NameLine());
282+
238283
}
239284

240285

241286
void cUK_Line3D_4BA::OnUpdate()
242287
{
243-
cPt3dr aNewP1 = mSeg.P1() + mNorm_x * mUkN1.Pt().x() + mNorm_y * mUkN1.Pt().y();
244-
cPt3dr aNewP2 = mSeg.P2() + mNorm_x * mUkN2.Pt().x() + mNorm_y * mUkN2.Pt().y();
288+
cPt3dr aNewP1 = mSeg.P1() + mNorm_x * mUkN1.x() + mNorm_y * mUkN1.y();
289+
cPt3dr aNewP2 = mSeg.P2() + mNorm_x * mUkN2.x() + mNorm_y * mUkN2.y();
245290

246291
mSeg = tSegComp3dr(aNewP1,aNewP2);
247292

248-
mUkN1.Pt() = cPt2dr(0,0);
249-
mUkN2.Pt() = cPt2dr(0,0);
293+
mUkN1 = cPt2dr(0,0);
294+
mUkN2 = cPt2dr(0,0);
250295

251296
InitNormals();
252297
}
@@ -296,8 +341,10 @@ void cUK_Line3D_4BA::AddOneEquation(tREAL8 aLambda,tREAL8 aWeight,const cOneData
296341

297342

298343
{
299-
mUkN1.PushIndexes(aVIndexes);
300-
mUkN2.PushIndexes(aVIndexes);
344+
345+
this->PushIndexes(aVIndexes);
346+
// mUkN1.PushIndexes(aVIndexes);
347+
// mUkN2.PushIndexes(aVIndexes);
301348

302349
for (auto & anObj : aData.mCam->GetAllUK())
303350
{
@@ -308,17 +355,35 @@ void cUK_Line3D_4BA::AddOneEquation(tREAL8 aLambda,tREAL8 aWeight,const cOneData
308355
mBA->Sys()->R_CalcAndAddObs(aData.SetAndGet_CalcEqSeg(),aVIndexes,aVObs,aWeight);
309356
}
310357

311-
void cUK_Line3D_4BA::AddEquation(tREAL8 aSigmaLine,int aNbPts)
358+
void cUK_Line3D_4BA::AddEquation()
312359
{
313-
for (int aKPt=0 ; aKPt<aNbPts ; aKPt++)
360+
for (int aKPt=0 ; aKPt<mNbPtSampling ; aKPt++)
314361
{
315-
tREAL8 aLambda = (aKPt+0.5) / aNbPts;
316-
tREAL8 aWeight = 1.0 / (Square(aSigmaLine) * aNbPts);
362+
tREAL8 aLambda = (aKPt+0.5) / mNbPtSampling;
363+
tREAL8 aWeight = 1.0 / (Square(mSigmaIm) * mNbPtSampling);
317364

318-
for (const auto & aData_L23 : mLineInit.Datas_L23())
365+
for (const auto & aData_L23 : mLineInit->Datas_L23())
319366
AddOneEquation(aLambda,aWeight,aData_L23);
320367
}
321368
}
322369

370+
void cMMVII_BundleAdj::AddLineAdjust(const std::vector<std::string> & aVParam)
371+
{
372+
tREAL8 aSigmaIm = cStrIO<double>::FromStr(aVParam.at(0));
373+
int aNbPts = cStrIO<int>::FromStr(aVParam.at(1));
374+
375+
mLineAdjust = new cUK_Line3D_4BA(mVSCPC,mPhProj,this,aSigmaIm,aNbPts);
376+
mSetIntervUK.AddOneObj(mLineAdjust);
377+
}
378+
379+
380+
381+
// cUK_Line3D_4BA::cUK_Line3D_4BA(const std::vector<cSensorCamPC *> & aVCam,cPhotogrammetricProject * aPhProj,cMMVII_BundleAdj * aBA) :
382+
383+
void cMMVII_BundleAdj::DeleteLineAdjust()
384+
{
385+
delete mLineAdjust;
386+
}
387+
323388

324389
};

MMVII/src/BundleAdjustment/cMMVII_BundleAdj.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ cMMVII_BundleAdj::cMMVII_BundleAdj(cPhotogrammetricProject * aPhp) :
104104
mNbIter (0),
105105
mVerbose (true),
106106
mShow_UC_UK (false),
107-
mRUCSUR (nullptr)
107+
mRUCSUR (nullptr),
108+
mLineAdjust (nullptr)
108109
{
109110
}
110111

@@ -120,6 +121,8 @@ cMMVII_BundleAdj::~cMMVII_BundleAdj()
120121
delete mRUCSUR;
121122
// DeleteAllAndClear(mGCP_UK);
122123
DeleteAllAndClear(mVBA_Lidar);
124+
125+
DeleteLineAdjust();
123126
}
124127

125128
void cMMVII_BundleAdj::ShowUKNames(const std::vector<std::string> & aParam, const std::string &aSuffix, cMMVII_Appli * anAppli)

0 commit comments

Comments
 (0)