diff --git a/MMVII/include/MMVII_PCSens.h b/MMVII/include/MMVII_PCSens.h index c2d8f7fda1..0385676513 100755 --- a/MMVII/include/MMVII_PCSens.h +++ b/MMVII/include/MMVII_PCSens.h @@ -152,6 +152,7 @@ class cDataPerspCamIntrCalib std::vector & VecInfo() ; const cMapPProj2Im& MapPProj2Im() const { return mMapPProj2Im;} + const std::string & Name() const; ///< Accessor protected : std::string mName; diff --git a/MMVII/include/MMVII_SysSurR.h b/MMVII/include/MMVII_SysSurR.h index ff16f990c0..fc11ca60a0 100755 --- a/MMVII/include/MMVII_SysSurR.h +++ b/MMVII/include/MMVII_SysSurR.h @@ -757,6 +757,12 @@ template class cSetInterUK_MultipeObj /// return a DenseVect filled with all unknowns as expected to create a cResolSysNonLinear cDenseVect GetVUnKnowns() const; + /// Nunmber of object + size_t NumberObject() const; + /// Access to kth object + const cObjWithUnkowns & KthObj(size_t) const; + cObjWithUnkowns & KthObj(size_t) ; + /// fills all unknown of object with a vector as created by cResolSysNonLinear::SolveUpdateReset() void SetVUnKnowns(const cDenseVect &); @@ -799,23 +805,32 @@ template class cGetAdrInfoParam typedef cObjWithUnkowns 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 & VAdrs() const; - const std::vector & VNames() const; - const std::vector & VObjs() const; + const std::vector & VAdrs() const; + const std::vector & VNames() const; + const std::vector & 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 mVObjs; - std::vector mVAdrs; + std::vector mVAdrs; std::vector mVNames; + std::string mNameType; + std::string mIdObj; }; template class cObjWithUnkowns // : public cObjOfMultipleObjUk @@ -861,8 +876,6 @@ template class cObjWithUnkowns // : public cObjOfMultipleObjUk & aVRes); - protected : /// defautl constructor, put non init in all vars void OUK_Reset(); @@ -890,14 +903,18 @@ template class cPtxdr_UK : public cObjWithUnkowns, public : typedef cPtxd 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 &) override; + private : cPtxdr_UK(const cPtxdr_UK&) = delete; tPt mPt; + std::string mName; }; typedef cPtxdr_UK<2> cPt2dr_UK ; diff --git a/MMVII/src/BundleAdjustment/BundleAdjustment.h b/MMVII/src/BundleAdjustment/BundleAdjustment.h index da3d2058e7..9b68f0e047 100644 --- a/MMVII/src/BundleAdjustment/BundleAdjustment.h +++ b/MMVII/src/BundleAdjustment/BundleAdjustment.h @@ -186,6 +186,8 @@ class cMMVII_BundleAdj void Save_newGCP(); void SaveTopo(); + void ShowUKNames() ; + private : //============== Methods ============================= diff --git a/MMVII/src/BundleAdjustment/Bundle_GCP.cpp b/MMVII/src/BundleAdjustment/Bundle_GCP.cpp index 817965fae7..6003f6da99 100644 --- a/MMVII/src/BundleAdjustment/Bundle_GCP.cpp +++ b/MMVII/src/BundleAdjustment/Bundle_GCP.cpp @@ -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); } @@ -269,11 +269,23 @@ void cMMVII_BundleAdj::Save_newGCP() /* cPt3dr_UK */ /* ---------------------------------------- */ -template cPtxdr_UK::cPtxdr_UK(const tPt & aPt) : - mPt (aPt) +template cPtxdr_UK::cPtxdr_UK(const tPt & aPt,const std::string& aName) : + mPt (aPt), + mName (aName) { } +std::vector VNameCoordsPt = {"x","y","z","t"}; + +template void cPtxdr_UK::GetAdrInfoParam(cGetAdrInfoParam & aGAIP) +{ + for (int aD=0 ; aD cPtxdr_UK::~cPtxdr_UK() { diff --git a/MMVII/src/BundleAdjustment/cAppliBundAdj.cpp b/MMVII/src/BundleAdjustment/cAppliBundAdj.cpp index 37fd997fb7..9b74e3aaa7 100644 --- a/MMVII/src/BundleAdjustment/cAppliBundAdj.cpp +++ b/MMVII/src/BundleAdjustment/cAppliBundAdj.cpp @@ -82,7 +82,7 @@ class cAppliBundlAdj : public cMMVII_Appli std::vector> mAddTieP; // In case there is multiple GCP Set std::vector mBRSigma; // RIGIDBLOC std::vector mBRSigma_Rat; // RIGIDBLOC - std::vector mParamRefOri; + std::vector mParamRefOri; // Force Poses to be +- equals to this reference int mNbIter; @@ -93,6 +93,8 @@ class cAppliBundlAdj : public cMMVII_Appli tREAL8 mLVM; ///< Levenberk Markard bool mMeasureAdded ; std::vector mVSharedIP; ///< Vector for shared intrinsic param + + bool mBAShowUKNames; ///< Do We Show the names of unknowns }; cAppliBundlAdj::cAppliBundlAdj(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec) : @@ -104,7 +106,8 @@ cAppliBundlAdj::cAppliBundlAdj(const std::vector & aVArgs,const cSp mGCPFilterAdd (""), mNbIter (10), mLVM (0.0), - mMeasureAdded (false) + mMeasureAdded (false), + mBAShowUKNames (false) { } @@ -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}}) // ]] ; } @@ -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 @@ -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); @@ -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 aVUk = mSetIntervUK.GetVUnKnowns() ; + StdOut() << "====== NBUK=" << aVUk.Sz() << "\n"; + size_t aKUk=0; + for (size_t aKObj=0 ; aKObj< mSetIntervUK.NumberObject() ; aKObj++) + { + cObjWithUnkowns & anObj = mSetIntervUK.KthObj(aKObj); + + cGetAdrInfoParam 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 &); + + } + getchar(); + // mSetIntervUK +} + + void cMMVII_BundleAdj::AssertPhaseAdd() { @@ -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 aGIP(mVPatShared[aKPat+1],*aPtrCal); + cGetAdrInfoParam aGIP(mVPatShared[aKPat+1],*aPtrCal,false); for (size_t aKParam=0 ; aKParam 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; diff --git a/MMVII/src/Matrix/cObjWithUnkowns.cpp b/MMVII/src/Matrix/cObjWithUnkowns.cpp index e8d5d2123c..4c79da2b31 100755 --- a/MMVII/src/Matrix/cObjWithUnkowns.cpp +++ b/MMVII/src/Matrix/cObjWithUnkowns.cpp @@ -21,16 +21,44 @@ template cGetAdrInfoParam::cGetAdrInfoParam(const std::string } */ -template cGetAdrInfoParam::cGetAdrInfoParam(const std::string & aPattern,cObjWithUnkowns & aObj) : +template cGetAdrInfoParam::cGetAdrInfoParam(const std::string & aPattern,cObjWithUnkowns & aObj,bool isRecurs) : // cGetAdrInfoParam(aPattern) - mPattern (AllocRegex(aPattern)) + mPattern (AllocRegex(aPattern)), + mNameType ("???"), + mIdObj ("???") { + if (isRecurs) + { + std::vector *> aVObj = aObj.RecursGetAllUK() ; + + for (auto aPtr : aVObj) + { + aPtr->GetAdrInfoParam(*this); + } + } + else + { + aObj.GetAdrInfoParam(*this); + } + /* std::vector *> aVObj = aObj.RecursGetAllUK() ; for (auto aPtr : aVObj) { aPtr->GetAdrInfoParam(*this); } + */ +} +template const std::string & cGetAdrInfoParam::NameType() const {return mNameType;} +template const std::string & cGetAdrInfoParam::IdObj() const {return mIdObj;} + +template void cGetAdrInfoParam::SetNameType(const std::string & aNameType) +{ + mNameType = aNameType; +} +template void cGetAdrInfoParam::SetIdObj(const std::string & aIdObj) +{ + mIdObj = aIdObj; } template void cGetAdrInfoParam::TestParam(tObjWUK * anObj,Type * anAdr,const std::string & aName) @@ -44,31 +72,33 @@ template void cGetAdrInfoParam::TestParam(tObjWUK * anObj,Typ } template const std::vector & cGetAdrInfoParam::VNames() const { return mVNames; } -template const std::vector & cGetAdrInfoParam::VAdrs() const {return mVAdrs;} +template const std::vector & cGetAdrInfoParam::VAdrs() const {return mVAdrs;} template const std::vector*>& cGetAdrInfoParam::VObjs() const {return mVObjs;} template void cGetAdrInfoParam::ShowAllParam(cObjWithUnkowns & anObj) { - cGetAdrInfoParam aGAIP(".*",anObj); + cGetAdrInfoParam aGAIP(".*",anObj,true); StdOut() << "=============== Avalaible names =================" << std::endl; for (const auto & aName : aGAIP.VNames()) StdOut() << " -[ " << aName << "]" << std::endl; } +/* template void cGetAdrInfoParam::PatternSetToVal(const std::string & aPattern,tObjWUK & aObj,const Type & aVal) { cGetAdrInfoParam aGAIP(aPattern,aObj); for (auto & anAdr : aGAIP.mVAdrs) *anAdr = aVal; } +*/ /* ******************************** */ /* cSetInterUK_MultipeObj */ /* ******************************** */ // put all value to "bull shit" -template cObjWithUnkowns::cObjWithUnkowns() +template cObjWithUnkowns::cObjWithUnkowns() { OUK_Reset(); } @@ -174,6 +204,23 @@ template cSetInterUK_MultipeObj::cSetInterUK_MultipeObj() : { } +template size_t cSetInterUK_MultipeObj::NumberObject() const +{ + return mVVInterv.size(); +} + +template const cObjWithUnkowns & cSetInterUK_MultipeObj::KthObj(size_t aKth) const +{ + return *(mVVInterv.at(aKth).mObj); +} +template cObjWithUnkowns & cSetInterUK_MultipeObj::KthObj(size_t aKth) +{ + return *(mVVInterv.at(aKth).mObj); +} + + + + template void cSetInterUK_MultipeObj::SIUK_Reset() { for (auto & aVinterv : mVVInterv) // parse object to reset them diff --git a/MMVII/src/Matrix/cResolSysNonLinear.cpp b/MMVII/src/Matrix/cResolSysNonLinear.cpp index 9012219c32..d3a485ca53 100755 --- a/MMVII/src/Matrix/cResolSysNonLinear.cpp +++ b/MMVII/src/Matrix/cResolSysNonLinear.cpp @@ -257,7 +257,7 @@ template void cResolSysNonLinear::SetFrozenAllCurrentValues( template void cResolSysNonLinear::SetFrozenFromPat(tObjWUk & anObjGlob,const std::string& aPat, bool Frozen) { - cGetAdrInfoParam aGIAP(aPat,anObjGlob); + cGetAdrInfoParam aGIAP(aPat,anObjGlob,false); for (size_t aK=0 ;aK aGAIP0(".*",aCal0); // Structure for extract param by names, all here + cGetAdrInfoParam aGAIP0(".*",aCal0,isRecursGAIP); // Structure for extract param by names, all here size_t aNbParam = aGAIP0.VAdrs().size(); std::vector > aVVParam(aNbParam); // will store all the value of a given param for (const auto & aPCal : aVCal) { - cGetAdrInfoParam aGAIPK(".*",*(aPCal)); + cGetAdrInfoParam aGAIPK(".*",*(aPCal),isRecursGAIP); for (size_t aKP=0 ; aKP & aGAIP) { + aGAIP.SetNameType("CalibCamPC"); + aGAIP.SetIdObj(mName); + aGAIP.TestParam(this,&(mMapPProj2Im.F()),"F"); aGAIP.TestParam(this,&(mMapPProj2Im.PP().x()),"PPx"); aGAIP.TestParam(this,&(mMapPProj2Im.PP().y()),"PPy"); diff --git a/MMVII/src/Sensors/cSensorCamPC.cpp b/MMVII/src/Sensors/cSensorCamPC.cpp index e5259fe122..9a525790a6 100644 --- a/MMVII/src/Sensors/cSensorCamPC.cpp +++ b/MMVII/src/Sensors/cSensorCamPC.cpp @@ -13,7 +13,7 @@ namespace MMVII { -cPoseWithUK::cPoseWithUK(const tPoseR & aPose) : +cPoseWithUK::cPoseWithUK(const tPoseR & aPose) : mPose (aPose), mOmega (0.0,0.0,0.0) { @@ -530,7 +530,9 @@ std::string cSensorCamPC::PrefixName() { return "PerspCentral";} void cSensorCamPC::GetAdrInfoParam(cGetAdrInfoParam & aGAIP) { - mPose_WU.GetAdrInfoParam(aGAIP); + aGAIP.SetNameType("PoseCamPC"); + aGAIP.SetIdObj(NameImage()); + mPose_WU.GetAdrInfoParam(aGAIP); } // ================= becnh =================== diff --git a/MMVII/src/Topo/ctopoobsset.cpp b/MMVII/src/Topo/ctopoobsset.cpp index bc44060187..9dddd112c0 100644 --- a/MMVII/src/Topo/ctopoobsset.cpp +++ b/MMVII/src/Topo/ctopoobsset.cpp @@ -8,7 +8,9 @@ namespace MMVII { cTopoObsSet::cTopoObsSet(cBA_Topo * aBA_Topo, eTopoObsSetType type): - mType(type), mBA_Topo(aBA_Topo), mInit(false) + mType(type), + mBA_Topo(aBA_Topo), + mInit(false) { } @@ -77,7 +79,7 @@ std::vector cTopoObsSet::getParamIndices() const //---------------------------------------------------------------- cTopoObsSetStation::cTopoObsSetStation(cBA_Topo *aBA_Topo) : cTopoObsSet(aBA_Topo, eTopoObsSetType::eStation), mOriStatus(eTopoStOriStat::eTopoStOriVert), - mRotSysCo2Vert(tRot::Identity()), mRotVert2Instr(tRot::Identity()), mRotOmega({0.,0.,0.}), + mRotSysCo2Vert(tRot::Identity()), mRotVert2Instr(tRot::Identity()), mRotOmega({0.,0.,0.},"OMEGA??"), mOriginName(""), mPtOrigin(nullptr) { }