Skip to content

Commit

Permalink
Merge branch 'mpd'
Browse files Browse the repository at this point in the history
  • Loading branch information
deseilligny committed Sep 25, 2024
2 parents 06e24bd + 24e6942 commit 685f395
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 36 deletions.
1 change: 1 addition & 0 deletions MMVII/include/MMVII_PCSens.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class cDataPerspCamIntrCalib
std::vector<std::string> & VecInfo() ;

const cMapPProj2Im& MapPProj2Im() const { return mMapPProj2Im;}
const std::string & Name() const; ///< Accessor

protected :
std::string mName;
Expand Down
33 changes: 25 additions & 8 deletions MMVII/include/MMVII_SysSurR.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,12 @@ template <class Type> class cSetInterUK_MultipeObj
/// return a DenseVect filled with all unknowns as expected to create a cResolSysNonLinear
cDenseVect<Type> GetVUnKnowns() const;

/// Nunmber of object
size_t NumberObject() const;
/// Access to kth object
const cObjWithUnkowns<Type> & KthObj(size_t) const;
cObjWithUnkowns<Type> & KthObj(size_t) ;

/// fills all unknown of object with a vector as created by cResolSysNonLinear::SolveUpdateReset()
void SetVUnKnowns(const cDenseVect<Type> &);

Expand Down Expand Up @@ -799,23 +805,32 @@ template <class Type> class cGetAdrInfoParam
typedef cObjWithUnkowns<Type> tObjWUK;

// cGetAdrInfoParam(const std::string & aPattern);
cGetAdrInfoParam(const std::string & aPattern,tObjWUK & aObj);
cGetAdrInfoParam(const std::string & aPattern,tObjWUK & aObj,bool Recurs);

static void PatternSetToVal(const std::string & aPattern,tObjWUK & aObj,const Type & aVal);

void TestParam(tObjWUK*,Type *,const std::string &);

const std::vector<Type*> & VAdrs() const;
const std::vector<std::string> & VNames() const;
const std::vector<tObjWUK*> & VObjs() const;
const std::vector<Type*> & VAdrs() const;
const std::vector<std::string> & VNames() const;
const std::vector<tObjWUK*> & VObjs() const;

static void ShowAllParam(tObjWUK &);

void SetNameType(const std::string & aNameType);
const std::string & NameType() const;
void SetIdObj(const std::string & aNameType);
const std::string & IdObj() const;


private :

tNameSelector mPattern;
std::vector<tObjWUK*> mVObjs;
std::vector<Type*> mVAdrs;
std::vector<Type*> mVAdrs;
std::vector<std::string> mVNames;
std::string mNameType;
std::string mIdObj;
};

template <class Type> class cObjWithUnkowns // : public cObjOfMultipleObjUk<Type>
Expand Down Expand Up @@ -861,8 +876,6 @@ template <class Type> class cObjWithUnkowns // : public cObjOfMultipleObjUk<Typ
int IndUk0() const; ///< Accessor
int IndUk1() const; ///< Accessor

// void GetAllValues(std::vector<Type> & aVRes);

protected :
/// defautl constructor, put non init in all vars
void OUK_Reset();
Expand Down Expand Up @@ -890,14 +903,18 @@ template <const int Dim> class cPtxdr_UK : public cObjWithUnkowns<tREAL8>,
public :
typedef cPtxd<tREAL8,Dim> tPt;

cPtxdr_UK(const tPt &);
cPtxdr_UK(const tPt &,const std::string& aName);
~cPtxdr_UK();
void PutUknowsInSetInterval() override;
const tPt & Pt() const ;
tPt & Pt() ;

void GetAdrInfoParam(cGetAdrInfoParam<tREAL8> &) override;

private :
cPtxdr_UK(const cPtxdr_UK&) = delete;
tPt mPt;
std::string mName;
};

typedef cPtxdr_UK<2> cPt2dr_UK ;
Expand Down
2 changes: 2 additions & 0 deletions MMVII/src/BundleAdjustment/BundleAdjustment.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class cMMVII_BundleAdj
void Save_newGCP();
void SaveTopo();

void ShowUKNames() ;

private :

//============== Methods =============================
Expand Down
18 changes: 15 additions & 3 deletions MMVII/src/BundleAdjustment/Bundle_GCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void cMMVII_BundleAdj::InitItereGCP()
{
for (const auto & aGCP : aPtr_BA_GCP->mMesGCP->MesGCP())
{
cPt3dr_UK * aPtrUK = new cPt3dr_UK(aGCP.mPt);
cPt3dr_UK * aPtrUK = new cPt3dr_UK(aGCP.mPt,aGCP.mNamePt);
aPtr_BA_GCP->mGCP_UK.push_back(aPtrUK);
mSetIntervUK.AddOneObj(aPtrUK);
}
Expand Down Expand Up @@ -269,11 +269,23 @@ void cMMVII_BundleAdj::Save_newGCP()
/* cPt3dr_UK */
/* ---------------------------------------- */

template <const int Dim> cPtxdr_UK<Dim>::cPtxdr_UK(const tPt & aPt) :
mPt (aPt)
template <const int Dim> cPtxdr_UK<Dim>::cPtxdr_UK(const tPt & aPt,const std::string& aName) :
mPt (aPt),
mName (aName)
{
}

std::vector<std::string> VNameCoordsPt = {"x","y","z","t"};

template <const int Dim> void cPtxdr_UK<Dim>::GetAdrInfoParam(cGetAdrInfoParam<tREAL8> & aGAIP)
{
for (int aD=0 ; aD<Dim ; aD++)
{
aGAIP.TestParam(this,&mPt[aD],VNameCoordsPt.at(aD));
}
aGAIP.SetNameType("GCP");
aGAIP.SetIdObj(mName);
}

template <const int Dim> cPtxdr_UK<Dim>::~cPtxdr_UK()
{
Expand Down
19 changes: 17 additions & 2 deletions MMVII/src/BundleAdjustment/cAppliBundAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class cAppliBundlAdj : public cMMVII_Appli
std::vector<std::vector<std::string>> mAddTieP; // In case there is multiple GCP Set
std::vector<double> mBRSigma; // RIGIDBLOC
std::vector<double> mBRSigma_Rat; // RIGIDBLOC
std::vector<std::string> mParamRefOri;
std::vector<std::string> mParamRefOri; // Force Poses to be +- equals to this reference

int mNbIter;

Expand All @@ -93,6 +93,8 @@ class cAppliBundlAdj : public cMMVII_Appli
tREAL8 mLVM; ///< Levenberk Markard
bool mMeasureAdded ;
std::vector<std::string> mVSharedIP; ///< Vector for shared intrinsic param

bool mBAShowUKNames; ///< Do We Show the names of unknowns
};

cAppliBundlAdj::cAppliBundlAdj(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) :
Expand All @@ -104,7 +106,8 @@ cAppliBundlAdj::cAppliBundlAdj(const std::vector<std::string> & aVArgs,const cSp
mGCPFilterAdd (""),
mNbIter (10),
mLVM (0.0),
mMeasureAdded (false)
mMeasureAdded (false),
mBAShowUKNames (false)
{
}

Expand Down Expand Up @@ -155,6 +158,7 @@ cCollecSpecArg2007 & cAppliBundlAdj::ArgOpt(cCollecSpecArg2007 & anArgOpt)
<< AOpt2007(mParamRefOri,"RefOri","Reference orientation [Ori,SimgaTr,SigmaRot?,PatApply?]",{{eTA2007::ISizeV,"[2,4]"}})
<< AOpt2007(mVSharedIP,"SharedIP","Shared intrinc parmaters [Pat1Cam,Pat1Par,Pat2Cam...] ",{{eTA2007::ISizeV,"[2,20]"}}) // ]]

<< AOpt2007(mBAShowUKNames,"ShowUKN","Show names of unknowns (tuning) ",{{eTA2007::HDV},{eTA2007::Tuning}}) // ]]
;
}

Expand Down Expand Up @@ -234,6 +238,7 @@ int cAppliBundlAdj::Exe()
}
*/

// ========== [0] initialisation of def values =============================
mPhProj.DPPointsMeasures().SetDirInIfNoInit(mDataDir);
mPhProj.DPMulTieP().SetDirInIfNoInit(mDataDir);
mPhProj.DPRigBloc().SetDirInIfNoInit(mDataDir); // RIGIDBLOC
Expand All @@ -244,6 +249,7 @@ int cAppliBundlAdj::Exe()
if (IsInit(&mParamRefOri))
mBA.AddReferencePoses(mParamRefOri);

// ========== [1] Read unkowns of bundle =============================
for (const auto & aNameIm : VectMainSet(0))
{
mBA.AddCam(aNameIm);
Expand Down Expand Up @@ -307,13 +313,17 @@ int cAppliBundlAdj::Exe()
mBA.AddCamBlocRig(aNameIm);
}


MMVII_INTERNAL_ASSERT_User(mMeasureAdded,eTyUEr::eUnClassedError,"Not any measure added");


// ========== [2] Make Iteration =============================
for (int aKIter=0 ; aKIter<mNbIter ; aKIter++)
{
mBA.OneIteration(mLVM);
}

// ========== [3] Save resulst =============================
for (auto & aSI : mBA.VSIm())
mPhProj.SaveSensor(*aSI);
/*
Expand All @@ -327,6 +337,11 @@ int cAppliBundlAdj::Exe()
mBA.Save_newGCP();
mBA.SaveTopo(); // just for debug for now

if (mBAShowUKNames)
{
mBA.ShowUKNames();
}

return EXIT_SUCCESS;
}

Expand Down
29 changes: 28 additions & 1 deletion MMVII/src/BundleAdjustment/cMMVII_BundleAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,33 @@ cMMVII_BundleAdj::~cMMVII_BundleAdj()
DeleteAllAndClear(mVGCP);
}

void cMMVII_BundleAdj::ShowUKNames()
{
StdOut() << "=================== ShowUKNamesShowUKNames ===============\n";


cDenseVect<tREAL8> aVUk = mSetIntervUK.GetVUnKnowns() ;
StdOut() << "====== NBUK=" << aVUk.Sz() << "\n";
size_t aKUk=0;
for (size_t aKObj=0 ; aKObj< mSetIntervUK.NumberObject() ; aKObj++)
{
cObjWithUnkowns<tREAL8> & anObj = mSetIntervUK.KthObj(aKObj);

cGetAdrInfoParam<tREAL8> aGIP (".*",anObj,false);
StdOut() << " ************ " << aGIP.NameType() << " : " << aGIP.IdObj() << "\n";
for (const auto & aN : aGIP.VNames())
{
StdOut() << " # " << aN << " : " << aVUk(aKUk) << "\n";
aKUk++;
}
// virtual void GetAdrInfoParam(cGetAdrInfoParam<Type> &);

}
getchar();
// mSetIntervUK
}



void cMMVII_BundleAdj::AssertPhaseAdd()
{
Expand Down Expand Up @@ -405,7 +432,7 @@ void cMMVII_BundleAdj::CompileSharedIntrinsicParams(bool ForAvg)
if (MatchRegex(aPtrCal->Name(),mVPatShared[aKPat]))
{
// Extract information on parameter macthing the pattern of params
cGetAdrInfoParam<tREAL8> aGIP(mVPatShared[aKPat+1],*aPtrCal);
cGetAdrInfoParam<tREAL8> aGIP(mVPatShared[aKPat+1],*aPtrCal,false);
for (size_t aKParam=0 ; aKParam<aGIP.VAdrs().size() ; aKParam++)
{
tREAL8 * aAdr = aGIP.VAdrs().at(aKParam);
Expand Down
8 changes: 4 additions & 4 deletions MMVII/src/Matrix/cLinearConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ void BenchFrozenAndShare()
{
cSetInterUK_MultipeObj<double> aSetIntervMultObj;

cPt3dr_UK pA( cPt3dr(100., 100.,100.) );
cPt3dr_UK pB( cPt3dr(110., 100.,100.) );
cPt3dr_UK pC( cPt3dr(110., 100.,100.) );
cPt3dr_UK rOmega( cPt3dr(0., 0.,0.) );
cPt3dr_UK pA( cPt3dr(100., 100.,100.),"A" );
cPt3dr_UK pB( cPt3dr(110., 100.,100.),"B" );
cPt3dr_UK pC( cPt3dr(110., 100.,100.),"C" );
cPt3dr_UK rOmega( cPt3dr(0., 0.,0.),"W" );

bool verbose = false;

Expand Down
57 changes: 52 additions & 5 deletions MMVII/src/Matrix/cObjWithUnkowns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,44 @@ template <class Type> cGetAdrInfoParam<Type>::cGetAdrInfoParam(const std::string
}
*/

template <class Type> cGetAdrInfoParam<Type>::cGetAdrInfoParam(const std::string & aPattern,cObjWithUnkowns<Type> & aObj) :
template <class Type> cGetAdrInfoParam<Type>::cGetAdrInfoParam(const std::string & aPattern,cObjWithUnkowns<Type> & aObj,bool isRecurs) :
// cGetAdrInfoParam<Type>(aPattern)
mPattern (AllocRegex(aPattern))
mPattern (AllocRegex(aPattern)),
mNameType ("???"),
mIdObj ("???")
{
if (isRecurs)
{
std::vector<cObjWithUnkowns<Type> *> aVObj = aObj.RecursGetAllUK() ;

for (auto aPtr : aVObj)
{
aPtr->GetAdrInfoParam(*this);
}
}
else
{
aObj.GetAdrInfoParam(*this);
}
/*
std::vector<cObjWithUnkowns<Type> *> aVObj = aObj.RecursGetAllUK() ;
for (auto aPtr : aVObj)
{
aPtr->GetAdrInfoParam(*this);
}
*/
}
template <class Type> const std::string & cGetAdrInfoParam<Type>::NameType() const {return mNameType;}
template <class Type> const std::string & cGetAdrInfoParam<Type>::IdObj() const {return mIdObj;}

template <class Type> void cGetAdrInfoParam<Type>::SetNameType(const std::string & aNameType)
{
mNameType = aNameType;
}
template <class Type> void cGetAdrInfoParam<Type>::SetIdObj(const std::string & aIdObj)
{
mIdObj = aIdObj;
}

template <class Type> void cGetAdrInfoParam<Type>::TestParam(tObjWUK * anObj,Type * anAdr,const std::string & aName)
Expand All @@ -44,31 +72,33 @@ template <class Type> void cGetAdrInfoParam<Type>::TestParam(tObjWUK * anObj,Typ
}

template <class Type> const std::vector<std::string> & cGetAdrInfoParam<Type>::VNames() const { return mVNames; }
template <class Type> const std::vector<Type*> & cGetAdrInfoParam<Type>::VAdrs() const {return mVAdrs;}
template <class Type> const std::vector<Type*> & cGetAdrInfoParam<Type>::VAdrs() const {return mVAdrs;}
template <class Type> const std::vector<cObjWithUnkowns<Type>*>& cGetAdrInfoParam<Type>::VObjs() const {return mVObjs;}

template <class Type> void cGetAdrInfoParam<Type>::ShowAllParam(cObjWithUnkowns<Type> & anObj)
{
cGetAdrInfoParam aGAIP(".*",anObj);
cGetAdrInfoParam<Type> aGAIP(".*",anObj,true);

StdOut() << "=============== Avalaible names =================" << std::endl;
for (const auto & aName : aGAIP.VNames())
StdOut() << " -[ " << aName << "]" << std::endl;
}

/*
template <class Type> void cGetAdrInfoParam<Type>::PatternSetToVal(const std::string & aPattern,tObjWUK & aObj,const Type & aVal)
{
cGetAdrInfoParam<Type> aGAIP(aPattern,aObj);
for (auto & anAdr : aGAIP.mVAdrs)
*anAdr = aVal;
}
*/

/* ******************************** */
/* cSetInterUK_MultipeObj */
/* ******************************** */

// put all value to "bull shit"
template <class Type> cObjWithUnkowns<Type>::cObjWithUnkowns()
template <class Type> cObjWithUnkowns<Type>::cObjWithUnkowns()
{
OUK_Reset();
}
Expand Down Expand Up @@ -174,6 +204,23 @@ template <class Type> cSetInterUK_MultipeObj<Type>::cSetInterUK_MultipeObj() :
{
}

template <class Type> size_t cSetInterUK_MultipeObj<Type>::NumberObject() const
{
return mVVInterv.size();
}

template <class Type> const cObjWithUnkowns<Type> & cSetInterUK_MultipeObj<Type>::KthObj(size_t aKth) const
{
return *(mVVInterv.at(aKth).mObj);
}
template <class Type> cObjWithUnkowns<Type> & cSetInterUK_MultipeObj<Type>::KthObj(size_t aKth)
{
return *(mVVInterv.at(aKth).mObj);
}




template <class Type> void cSetInterUK_MultipeObj<Type>::SIUK_Reset()
{
for (auto & aVinterv : mVVInterv) // parse object to reset them
Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Matrix/cResolSysNonLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ template <class Type> void cResolSysNonLinear<Type>::SetFrozenAllCurrentValues(
template <class Type>
void cResolSysNonLinear<Type>::SetFrozenFromPat(tObjWUk & anObjGlob,const std::string& aPat, bool Frozen)
{
cGetAdrInfoParam<Type> aGIAP(aPat,anObjGlob);
cGetAdrInfoParam<Type> aGIAP(aPat,anObjGlob,false);
for (size_t aK=0 ;aK<aGIAP.VAdrs().size() ; aK++)
{
Type * anAdr =aGIAP.VAdrs()[aK];
Expand Down
Loading

0 comments on commit 685f395

Please sign in to comment.