@@ -45,6 +45,7 @@ class cBA_BlockInstr : public cMemCheck
4545
4646 // For a given pair of Poses, add the constraint of rigidity
4747 void OneItere_1PairCam (const cIrb_SigmaInstr&,cIrbComp_TimeS&, const tNamePair & aPair);
48+ void OneIter_Rattach1Cam (const cIrb_Desc1Intsr&);
4849
4950
5051 cMMVII_BundleAdj& mBA ; // < Bundle Adj Struct
@@ -65,6 +66,11 @@ class cBA_BlockInstr : public cMemCheck
6566 std::map<tNamePair,cIrb_SigmaInstr> mSigmaPair ; // < Sigma a posteriori for pair of images
6667 cWeightAv<tREAL8,tREAL8> mAvgTr ;
6768 cWeightAv<tREAL8,tREAL8> mAvgRot ;
69+ std::map<std::string,tPoseR> mPoseInit ; // < Used in case of rattachment
70+ bool mUseRat2CurrBR ; // < Is there rattachment to current
71+ tREAL8 mSigTrCurBR ; // <
72+ tREAL8 mSigRotCurBR ; // <
73+
6874};
6975
7076cResolSysNonLinear<tREAL8> & cBA_BlockInstr::Sys ()
@@ -84,36 +90,39 @@ cBA_BlockInstr::cBA_BlockInstr
8490 const std::vector<std::string> & aVParamGauje,
8591 const std::vector<std::string> & aVParamCur
8692) :
87- mBA (aBA),
88- mSys (nullptr ),
89- mCompbBl (aCompBl),
90- mCalBl (&mCompbBl ->CalBlock ()),
91- mCalCams (&mCalBl ->SetCams ()),
92- mMasterCam (mCalCams ->MasterCam ()),
93- mVParams (aVParamsPair),
94- mEqRigCam (EqBlocRig(true ,1 ,true )),
95- mMulSigmaTr (cStrIO<double >::FromStr(GetDef(aVParamsPair,1 ,std::string(" 1.0" )))),
96- mMulSigmaRot (cStrIO<double >::FromStr(GetDef(aVParamsPair,2 ,std::string(" 1.0" )))),
97- mModeSaveSigma(cStrIO<int >::FromStr(GetDef(aVParamsPair,3 ,std::string(" 1" )))),
98- mGaujeTr (cStrIO<double >::FromStr(GetDef(aVParamGauje,0 ,std::string(" 0.0" )))),
99- mGaujeRot (cStrIO<double >::FromStr(GetDef(aVParamGauje,1 ,std::string(" 0.0" ))))
93+ mBA (aBA),
94+ mSys (nullptr ),
95+ mCompbBl (aCompBl),
96+ mCalBl (&mCompbBl ->CalBlock ()),
97+ mCalCams (&mCalBl ->SetCams ()),
98+ mMasterCam (mCalCams ->MasterCam ()),
99+ mVParams (aVParamsPair),
100+ mEqRigCam (EqBlocRig(true ,1 ,true )),
101+ mMulSigmaTr (cStrIO<double >::FromStr(GetDef(aVParamsPair,1 ,std::string(" 1.0" )))),
102+ mMulSigmaRot (cStrIO<double >::FromStr(GetDef(aVParamsPair,2 ,std::string(" 1.0" )))),
103+ mModeSaveSigma (cStrIO<int >::FromStr(GetDef(aVParamsPair,3 ,std::string(" 1" )))),
104+ mGaujeTr (cStrIO<double >::FromStr(GetDef(aVParamGauje,0 ,std::string(" 0.0" )))),
105+ mGaujeRot (cStrIO<double >::FromStr(GetDef(aVParamGauje,1 ,std::string(" 0.0" )))),
106+ mUseRat2CurrBR (! aVParamCur.empty())
100107{
101108
102- if (! aVParamCur.empty ())
103- {
104- for (auto & aCalC : mCalCams ->VCams () )
105- {
106- mBA .SetIntervUK ().AddOneObj (&aCalC.PoseUKInBlock ());
107- }
108- }
109- // Add all the pose to construct the Time-Stamp structure
109+
110+ // Add amWithCurrll the pose to construct the Time-Stamp structure
110111 for (auto aPtrCam : mBA .VSCPC ())
111112 mCompbBl ->AddImagePose (aPtrCam,true );
112113
113114 // communicate to the system of equation the unknowns of the bloc
114115 for (auto & aCalC : mCalCams ->VCams () )
115116 {
116117 mBA .SetIntervUK ().AddOneObj (&aCalC.PoseUKInBlock ());
118+ mPoseInit [aCalC.NameCal ()]= aCalC.PoseUKInBlock ().Pose ();
119+ }
120+
121+ if (mUseRat2CurrBR )
122+ {
123+ MMVII_INTERNAL_ASSERT_always (aVParamCur.size ()==2 ," Bad size for Block-Rat to Cur Block Rigid" );
124+ mSigTrCurBR = cStrIO<double >::FromStr (aVParamCur.at (0 ));
125+ mSigRotCurBR = cStrIO<double >::FromStr (aVParamCur.at (1 ));
117126 }
118127}
119128
@@ -127,6 +136,24 @@ cIrbCal_Block & cBA_BlockInstr::CalBl()
127136 return *mCalBl ;
128137}
129138
139+ void cBA_BlockInstr::OneIter_Rattach1Cam (const cIrb_Desc1Intsr& aDesc)
140+ {
141+
142+ int aKCam = mCalCams ->IndexCamFromNameCalib (aDesc.NameInstr ());
143+
144+ if (aKCam<0 ) return ;
145+
146+ cPoseWithUK & aPUK = mCalCams ->KthCam (aKCam).PoseUKInBlock ();
147+ tPoseR aP0 = *MapGet (mPoseInit ,aDesc.NameInstr ());
148+
149+ StdOut () << " OneIter_Rattach1CamOneIter_Rattach1Cam "
150+ << aDesc.NameInstr ()
151+ << " Tr=" << aPUK.Pose ().Tr () -aP0.Tr ()
152+ << " Rot=" << (aPUK.Pose ().Rot ()*aP0.Rot ().MapInverse ()).ToWPK ()
153+ << " \n " ;
154+
155+ }
156+
130157
131158void cBA_BlockInstr::OneItere_1PairCam
132159 (
@@ -215,7 +242,7 @@ void cBA_BlockInstr::OneItere_1PairCam
215242
216243void cBA_BlockInstr::OneItere_1TS (cIrbComp_TimeS& aDataS)
217244{
218- for (auto & [aPair,aSigma2] : mCalBl ->SigmaPair () )
245+ for ( auto & [aPair,aSigma2] : mCalBl ->SigmaPair () )
219246 {
220247 const cIrb_Desc1Intsr & aSI1 = mCalBl ->DescrIndiv (aPair.V1 ());
221248 const cIrb_Desc1Intsr & aSI2 = mCalBl ->DescrIndiv (aPair.V2 ());
@@ -226,6 +253,9 @@ void cBA_BlockInstr::OneItere_1TS(cIrbComp_TimeS& aDataS)
226253 else
227254 MMVII_INTERNAL_ERROR (" Unhandled combination of instrument in cBA_BlockInstr::OneItere_1TS" );
228255 }
256+
257+
258+ // for ()
229259}
230260
231261
@@ -242,6 +272,14 @@ void cBA_BlockInstr::OneItere()
242272 OneItere_1TS (aDataTS);
243273 }
244274
275+ for ( auto & [aNameCal,aDescr] : mCalBl ->DescrIndiv () )
276+ {
277+ if (aDescr.Type () == eTyInstr::eCamera)
278+ {
279+ OneIter_Rattach1Cam (aDescr);
280+ }
281+ }
282+
245283 AddGauge (true );
246284
247285 StdOut () << " Avg Tr:" << std::sqrt (mAvgTr .Average ()) << " Rot:" << std::sqrt (mAvgRot .Average ()) << " \n " ;
0 commit comments