@@ -628,9 +628,12 @@ template <typename TypeDist,typename TypeProj> class cEqColinearityCamPPC
628628 }
629629 std::vector<std::string> VNamesUnknowns () const
630630 {
631+ std::vector<std::string> aVUkGround = mLine ?
632+ Append (NamesP2 (" N1Coords" ),NamesP2 (" N2Coords" )) :
633+ NamesP3 (" PGround" ) ;
631634 return Append
632635 (
633- NamesP3 ( " PGround " ), // 0-3
636+ aVUkGround,
634637 NamesPose (" CCam" ," W" ), // 3-9
635638 NamesIntr (" " ), // 9-12
636639 mDist .VNamesParams ()
@@ -639,6 +642,19 @@ template <typename TypeDist,typename TypeProj> class cEqColinearityCamPPC
639642
640643 std::vector<std::string> VNamesObs () const
641644 {
645+ if (mLine )
646+ {
647+ std::vector<std::string> aVecLIne2D = Append (NamesP2 (" Line2D_Pt" ),NamesP2 (" Line2D_Norm" ));
648+
649+ std::vector<std::string> aVPtsLine = Append (NamesP3 (" Line3d_Pt1" ),NamesP3 (" Line3d_Pt2" ));
650+ std::vector<std::string> aVPtsNormLine = Append (NamesP3 (" Line3d_Norm_x" ),NamesP3 (" Line3d_Norm_y" ));
651+ std::vector<std::string> aVLambdaLine {" Line3d_Lambda" };
652+
653+ std::vector<std::string> aVecLIne3D = Append (aVPtsLine,aVPtsNormLine,aVLambdaLine);
654+
655+
656+ return Append (aVecLIne2D,aVecLIne3D,NamesMatr (" M" ,cPt2di (3 ,3 )));
657+ }
642658 return Append (NamesP2 (" Im" ),NamesMatr (" M" ,cPt2di (3 ,3 )));
643659 }
644660
@@ -649,15 +665,43 @@ template <typename TypeDist,typename TypeProj> class cEqColinearityCamPPC
649665 const std::vector<tUk> & aVObs
650666 ) const
651667 {
668+ tUk aC1 = CreateCste (1.0 ,aVUk.at (0 ));
669+ cPtxd<tUk,3 > aPGround;
670+ size_t aIndUk = 0 ;
671+ size_t aIndObs = 0 ;
672+
673+ cPtxd<tUk,2 > aPtIm = VtoP2AutoIncr (aVObs,&aIndObs);
674+ cPtxd<tUk,2 > aPtNormIm;
675+ if (mLine )
676+ {
677+ aPtNormIm = VtoP2AutoIncr (aVObs,&aIndObs);
678+
679+ cPtxd<tUk,3 > aP3d_1 = VtoP3AutoIncr (aVObs,&aIndObs);
680+ cPtxd<tUk,3 > aP3d_2 = VtoP3AutoIncr (aVObs,&aIndObs);
681+
682+ cPtxd<tUk,3 > aNorm3d_x = VtoP3AutoIncr (aVObs,&aIndObs);
683+ cPtxd<tUk,3 > aNorm3d_y = VtoP3AutoIncr (aVObs,&aIndObs);
684+ tUk aLambda = aVObs.at (aIndObs++);
685+
686+ cPtxd<tUk,2 > aWeightN_1 = VtoP2AutoIncr (aVUk,&aIndUk);
687+ cPtxd<tUk,2 > aWeightN_2 = VtoP2AutoIncr (aVUk,&aIndUk);
688+
689+ cPtxd<tUk,3 > aQ1 = aP3d_1 + aNorm3d_x * aWeightN_1.x () + aNorm3d_y * aWeightN_1.y () ;
690+ cPtxd<tUk,3 > aQ2 = aP3d_2 + aNorm3d_x * aWeightN_2.x () + aNorm3d_y * aWeightN_2.y () ;
691+
692+ aPGround = aQ1 * (aC1-aLambda) + aQ2 * aLambda ;
693+ }
652694 // extract unknown parameters from vector
653- cPtxd<tUk,3 > aPGround = VtoP3 (aVUk,0 );
654- cPtxd<tUk,3 > aCCcam = VtoP3 (aVUk,3 );
655- cPtxd<tUk,3 > aW = VtoP3 (aVUk,6 );
656- tUk aFoc = aVUk.at (9 );
657- cPtxd<tUk,2 > aPP = VtoP2 (aVUk,10 );
695+ else
696+ {
697+ // aPGround = VtoP3(aVUk,0);
698+ aPGround = VtoP3AutoIncr (aVUk,&aIndUk);
699+ }
700+ cPtxd<tUk,3 > aCCcam = VtoP3AutoIncr (aVUk,&aIndUk);
701+ cPtxd<tUk,3 > aW = VtoP3AutoIncr (aVUk,&aIndUk);
702+ tUk aFoc = aVUk.at (aIndUk++);
703+ cPtxd<tUk,2 > aPP = VtoP2AutoIncr (aVUk,&aIndUk);
658704
659- // obs pixel
660- cPtxd<tUk,2 > aPtIm = VtoP2 (aVObs,0 );
661705
662706 cPtxd<tUk,3 > aVCP = aPGround - aCCcam; // vector CenterCam -> PGround
663707
@@ -669,7 +713,10 @@ template <typename TypeDist,typename TypeProj> class cEqColinearityCamPPC
669713 */
670714
671715#else
672- cMatF<tUk> aRotInit (3 ,3 ,aVObs,2 );
716+ // cMatF<tUk> aRotInit (3,3,aVObs,2);
717+ cMatF<tUk> aRotInit (3 ,3 ,&aIndObs,aVObs);
718+ // cMatF(size_t aSzX,size_t aSzY, size_t * anIndAutoIncr, const std::vector<Type> & aVal) :
719+
673720 cMatF<tUk> aDeltaRot = cMatF<tUk>::MatAxiator (aW);
674721 cPtxd<tUk,3 > aPCam = aDeltaRot * (aRotInit * aVCP);
675722#endif
@@ -679,9 +726,19 @@ template <typename TypeDist,typename TypeProj> class cEqColinearityCamPPC
679726
680727 cPtxd<tUk,2 > aPPix = aPP + aPDist * aFoc; // Use Focal and PP to make pixel
681728
682- cPtxd<tUk,2 > aResidual = aPPix - aPtIm; // compare to mesured point
683729
684- return {aResidual.x (),aResidual.y ()};
730+ MMVII_INTERNAL_ASSERT_always (aIndUk+mDist .VNamesParams ().size ()==aVUk.size ()," cEqColinearityCamPPC : Uk-size" );
731+ MMVII_INTERNAL_ASSERT_always (aIndObs== aVObs.size ()," cEqColinearityCamPPC : Obs-size" );
732+
733+ cPtxd<tUk,2 > aResidual = aPPix - aPtIm; // compare to mesured point
734+ if (mLine )
735+ {
736+ return {Scal (aPtNormIm,aResidual)};
737+ }
738+ else
739+ {
740+ return {aResidual.x (),aResidual.y ()};
741+ }
685742 }
686743
687744 TypeDist mDist ;
0 commit comments