@@ -22,6 +22,8 @@ class cOneData_L23 : public cMemCheck
2222 cLineDist_Manifold* SetAndGet_LineM () const ;
2323 // / create, if dont exist, calculator for line-adjustment
2424 cCalculator<tREAL8> * SetAndGet_CalcEqSeg () const ;
25+ cWeightAv<tREAL8,tREAL8> & AvgResidual () ; // / Accessor
26+
2527
2628
2729 cSensorCamPC * mCam ; // < camera seeing the line
@@ -31,10 +33,10 @@ class cOneData_L23 : public cMemCheck
3133 private :
3234 mutable cLineDist_Manifold* mLineM ;
3335 mutable cCalculator<tREAL8> * mCalcEqSeg ;
36+ cWeightAv<tREAL8,tREAL8> mAvgResidual ;
3437};
3538
3639
37-
3840// / class to handle computation
3941class cCam2_Line_2Dto3D : public cMemCheck
4042{
@@ -44,6 +46,8 @@ class cCam2_Line_2Dto3D : public cMemCheck
4446 const tSegComp3dr & Seg3d () const ; // < Accessor
4547 const std::string & NameLine () const ; // < Accessor
4648 const std::vector<cOneData_L23> & Datas_L23 () const ; // < Accessor
49+ std::vector<cOneData_L23> & Datas_L23 () ; // < Accessor
50+
4751 cPt3dr PtOfWeight (const tREAL8 aWeight);
4852
4953 private :
@@ -71,8 +75,8 @@ class cUK_Line3D_4BA : public cObjWithUnkowns<tREAL8>
7175 private :
7276
7377
74- cUK_Line3D_4BA (const cUK_Line3D_4BA &) = delete ;
75- void AddOneEquation (tREAL8 aLambda, tREAL8 aWeight,const cOneData_L23&);
78+ cUK_Line3D_4BA (const cUK_Line3D_4BA &) = delete ;
79+ void AddOneEquation (tREAL8 aLambda, tREAL8 aWeight,cOneData_L23&);
7680 void InitNormals ();
7781
7882 // / "reaction" after linear update
@@ -135,6 +139,12 @@ cCalculator<tREAL8> * cOneData_L23::SetAndGet_CalcEqSeg() const
135139 return mCalcEqSeg ;
136140}
137141
142+ cWeightAv<tREAL8,tREAL8> & cOneData_L23::AvgResidual ()
143+ {
144+ return mAvgResidual ;
145+ }
146+
147+
138148/* *********************************************************** */
139149/* */
140150/* cCam2_Line_2Dto3D */
@@ -219,7 +229,10 @@ const std::vector<cOneData_L23> & cCam2_Line_2Dto3D::Datas_L23() const
219229{
220230 return mDatas_L23 ;
221231}
222-
232+ std::vector<cOneData_L23> & cCam2_Line_2Dto3D::Datas_L23 ()
233+ {
234+ return mDatas_L23 ;
235+ }
223236/* *********************************************************** */
224237/* */
225238/* cUK_Line3D_4BA */
@@ -298,7 +311,7 @@ void cUK_Line3D_4BA::OnUpdate()
298311}
299312
300313
301- void cUK_Line3D_4BA::AddOneEquation (tREAL8 aLambda,tREAL8 aWeight,const cOneData_L23& aData)
314+ void cUK_Line3D_4BA::AddOneEquation (tREAL8 aLambda,tREAL8 aWeight,cOneData_L23& aData)
302315{
303316 std::vector<double > aVObs ;
304317 std::vector<int > aVIndexes;
@@ -318,6 +331,19 @@ void cUK_Line3D_4BA::AddOneEquation(tREAL8 aLambda,tREAL8 aWeight,const cOneData
318331 cPt2dr aTgtL2 = aLDM->TgSpace (aPImOnL2).at (0 );
319332 cPt2dr aNormL2 = Rot90 (aTgtL2);
320333
334+ tREAL8 aResidual= Norm2 (aPImPG-aPImOnL2);
335+ {
336+ auto aCalib = aData.mCam ->InternalCalib ();
337+ const tSeg2dr aSegD = aData.mSeg ;
338+
339+ tSegComp2dr aSeg_UD (aCalib->Undist (aSegD.P1 ()),aCalib->Undist (aSegD.P2 ()));
340+ cPt2dr aP_UD = aCalib->Undist (aPImPG);
341+
342+ StdOut () << " ** RRRR " << aResidual << " DD=" << aSeg_UD.Dist (aP_UD) << " \n " ;
343+
344+ // const tSeg2dr mSeg
345+ }
346+ aData.AvgResidual ().Add (1.0 ,aResidual);
321347// StdOut() << " PIMG=" << aPImPG << " PL=" << aPImOnL2 << "\n";
322348
323349 // std::vector<std::string> aVecLIne2D = Append(NamesP2("Line2D_Pt"),NamesP2("Line2D_Norm"));
@@ -360,12 +386,15 @@ void cUK_Line3D_4BA::AddOneEquation(tREAL8 aLambda,tREAL8 aWeight,const cOneData
360386
361387void cUK_Line3D_4BA::AddEquation ()
362388{
389+ for ( auto & aData_L23 : mLineInit ->Datas_L23 ())
390+ aData_L23.AvgResidual ().Reset ();
391+
363392 for (int aKPt=0 ; aKPt<mNbPtSampling ; aKPt++)
364393 {
365394 tREAL8 aLambda = (aKPt+0.5 ) / mNbPtSampling ;
366395 tREAL8 aWeight = 1.0 / (Square (mSigmaIm ) * mNbPtSampling );
367396
368- for (const auto & aData_L23 : mLineInit ->Datas_L23 ())
397+ for ( auto & aData_L23 : mLineInit ->Datas_L23 ())
369398 AddOneEquation (aLambda,aWeight,aData_L23);
370399 }
371400}
0 commit comments