Пример #1
0
void cAppliApero::SimuleOneLiaison
     (
         const cGenerateLiaisons & aGL,
	 const std::list<Pt3dr>  & aLP3,
         cPoseCam & aCam1,
         cPoseCam & aCam2
     )
{
   const CamStenope * aCS1 = aCam1.CurCam();
   const CamStenope * aCS2 = aCam2.CurCam();

   ElPackHomologue aPack;

   for(std::list<Pt3dr>::const_iterator itP3=aLP3.begin();itP3!=aLP3.end();itP3++)
   {
      Pt2dr aPIm1 = aCS1->R3toF2(*itP3)+Pt2dr(NRrandC(),NRrandC())*aGL.BruitIm1();
      Pt2dr aPIm2 = aCS2->R3toF2(*itP3)+Pt2dr(NRrandC(),NRrandC())*aGL.BruitIm2();

      aPack.Cple_Add(ElCplePtsHomologues(aPIm1,aPIm2));
   }

   std::string aName = mDC+mICNM->Assoc1To2(aGL.KeyAssoc(),aCam1.Name(),aCam2.Name(),true);
   cElXMLFileIn aFileXML(aName);
   aFileXML.PutPackHom(aPack);
}
Пример #2
0
cBenchLeastSquare::cBenchLeastSquare
(
    INT aNbVar,
    INT aNbEq,
    bool SomForm
)  :
   FoncNVarDer<REAL> (aNbVar),
   mNbVar (aNbVar),
   mNbEq  (aNbEq),
   mSys (aNbVar,aNbEq),
   mSol (1),
   mSolEps (aNbVar),  
   mTmpVF  (aNbVar),
   mDataTmpVF (mTmpVF.data())
{
   Im1D_REAL8 aFLin(aNbVar);
   REAL8* aDLin = aFLin.data();

   for (INT iEq = 0 ; iEq < aNbEq ; iEq++)
   {
       for (INT iVar=0 ; iVar<aNbVar ; iVar++)
       {
	    if (SomForm)
	    {
		if (iEq<2*aNbVar)
	           aDLin[iVar] = (iVar==(iEq%mNbVar));
		else
	           aDLin[iVar] = NRrandC() * (NRrandC()>0);
	    }
	    else
	       aDLin[iVar] = NRrandC();
       }
       mSys.PushEquation
       (
           aFLin,
	   NRrandC() * 1e3,
	   0.1 + NRrandom3()
       );
   }

   bool Ok;
   mSol = mSys.L2Solve(&Ok);
   mResidu = mSys.L2SomResiduPond(mSol);
   BENCH_ASSERT(Ok);

   for (INT k=0 ; k< 200 ; k++)
   {
	ELISE_COPY
	(
	    mSolEps.all_pts(),
	    mSol.in() + (frandr()-0.5),
	    mSolEps.out()
	);
	REAL ResEps =  mSys.L2SomResiduPond(mSolEps);
	 // cout << (ResEps-mResidu) << " " << mResidu << "\n";
	BENCH_ASSERT(ResEps>mResidu);
   }
   // getchar();
}
Пример #3
0
void cDistorBilin::Randomize(double aFact)
{
   for (int aKY=0 ; aKY<= mNb.y ; aKY++)
   {
       for (int aKX=0 ; aKX<= mNb.x ; aKX++)
       {
             Dist(Pt2di(aKX,aKY)) = FromCoordGrid(Pt2dr(aKX,aKY) + Pt2dr(NRrandC(),NRrandC()) * aFact);
       }
   }
}
cMEPCoCentrik::cMEPCoCentrik(const ElPackHomologue & aPack,double aFoc,bool aShow,const ElRotation3D * aRef,bool Quick) :
    mPack (aPack),
    mRef  (aRef),
    mFoc  (aFoc),
    mCostMin (1e9),
    mDoPly   (true),
    mEcartCo (1e9),
    mMatRPur (1,1),
    mShow    (aShow),
    mSolVraiR (ElRotation3D::Id),
    mCostVraiR (1e20),
    mQuick    (Quick)
{
     InitPackME(mVP1,mVP2,mVPds,aPack);

     ElTimer aChrono;
     mMatRPur =  GlobMepRelCocentrique(mEcartCo,mPack,NbRanCoCInit,aPack.size());
     mMatRPur = mMatRPur.transpose() ; // Retour aux convention 2 = > 1

     // Car un peu optimiste comme estim init
     mEcartCo *= 1.5;


     if (0)   // OK la descente est validee
     {
          double aNoise = 1e-2;
          ElMatrix<double> aMP =  ElMatrix<double>::Rotation(aNoise*NRrandC(),aNoise*NRrandC(),aNoise*NRrandC());
          mMatRPur = mMatRPur *  aMP;
     }

     for (int aK=0 ; aK<10 ; aK++)
     {
         OneItereRotPur(mMatRPur,mEcartCo);
     }


     if (!mQuick)
         Test(aPack,mMatRPur,aRef,mEcartCo);
}
Пример #5
0
void TestRandomSetOfMesureSegDr()
{
    std::string aInput="/media/data1/ExempleDoc/Test-CompDrAnalogik/MesureLineImageOri.xml";
    std::string aOut="/media/data1/ExempleDoc/Test-CompDrAnalogik/MesureLineImage.xml";


    cSetOfMesureSegDr aSMS = StdGetFromPCP(aInput,SetOfMesureSegDr);

   for
   (
       std::list<cMesureAppuiSegDr1Im>::iterator itIm=aSMS.MesureAppuiSegDr1Im().begin();
       itIm!=aSMS.MesureAppuiSegDr1Im().end();
       itIm++
   )
   {
      std::string aNameIm = itIm->NameIm();
      {

         for
         (
            std::list<cOneMesureSegDr>::iterator itMes=itIm->OneMesureSegDr().begin();
            itMes!=itIm->OneMesureSegDr().end();
            itMes++
         )
         {
             Pt2dr aP1 = itMes->Pt1Im();
             Pt2dr aP2 = itMes->Pt2Im();
             SegComp aSeg(aP1,aP2);
             itMes->Pt1Im() = aSeg.from_rep_loc(Pt2dr(0.6+NRrandC(),0));
             itMes->Pt2Im() = aSeg.from_rep_loc(Pt2dr(0.4-NRrandC(),0));
         }
      }
   }

    MakeFileXML(aSMS,aOut);

    exit(0);
}
Пример #6
0
void Bench_Rank()
{
    std::cout << "Begin Bench Rank \n";
   
    for (int aTime=0 ; aTime<10000; aTime++)
    {
        int aNb = round_ni(1 + ElSquare(10*NRrandom3()));
        std::vector<double> aV;
        for (int aK=0 ; aK<aNb ; aK++)
           aV.push_back(NRrandC());

        for (int aK=0 ; aK < aNb ; aK++)
        {
            for (int aK2=0 ; aK2 < 3 ; aK2++)
                if (NRrandom3()<0.2)
                   aV.push_back(aV[aK]);

            for (int aK2=0 ; aK2 < int(aV.size()) ; aK2++)
                if (NRrandom3()<0.02)
                   aV[aK2] = aV[aK];
         }

        aNb = aV.size();

        std::vector<double>  aV2 = aV;
        std::vector<double>  aV3 = aV;

         int aRnk = NRrandom3(aNb);

         double aVK =KthVal(VData(aV),aNb,aRnk);

         std::sort(aV2.begin(),aV2.end());
         double aVK2 = aV2[aRnk];

         // std::cout << "Bench Rank " << aVK-aVK2 << "\n";
         ELISE_ASSERT(ElAbs(aVK-aVK2)<1e-10,"Bench rnk");

/*
   Ne marche pas : la valeur RrnK est n'importe ou

         SplitArrounKthValue(VData(aV3),aNb,aRnk);
         double aVK3 = aV3[aRnk];
         std::cout << "Bench Rank " << aVK-aVK2 << " " << aVK-aVK3<< "\n";
         ELISE_ASSERT(ElAbs(aVK-aVK2)<1e-10,"Bench rnk");
         ELISE_ASSERT(ElAbs(aVK-aVK3)<1e-10,"Bench rnk");
*/

    }
    std::cout << "OK BENCH RANK \n";
}
Пример #7
0
void cAppliApero::InitPointsTerrain
     (
          std::list<Pt3dr>  & aL, 
          const cGPtsTer_By_ImProf & aGBI
     )
{
   const CamStenope * aMasterCam = 0;
   if (aGBI.ImMaitresse().IsInit())
      aMasterCam = PoseFromName(aGBI.ImMaitresse().Val())->CurCam();

   std::string aNF =  DC() + aGBI.File();
   Im2D_REAL4 aMnt = Im2D_REAL4::FromFileStd(aNF);
   TIm2D<REAL4,REAL8> aTMnt(aMnt);
   Pt2di aSz = aMnt.sz();

   int aNb = aGBI.NbPts();
   Pt2di aPtNbXY(0,0);
   Pt2dr aPtPas(0,0);
   if (aGBI.OnGrid())
   {
      double aPas = sqrt(aSz.x*aSz.y/double(aNb));
      aPtNbXY = Pt2di
              (
	         round_up(aSz.x/aPas),
	         round_up(aSz.y/aPas)
              );

       aNb = aPtNbXY.x * aPtNbXY.y;
       aPtPas = Pt2dr(double(aSz.x)/aPtNbXY.x,double(aSz.y)/aPtNbXY.y);
   }

   for (int aKP=0 ; aKP<aNb ; aKP++)
   {
       Pt2dr aPPl(0,0);

       if (aGBI.OnGrid())
       {
           int aKX = aKP %  aPtNbXY.x;
           int aKY = aKP /  aPtNbXY.x;
	   double aMul = 0.5 * aGBI.RandomizeInGrid().Val();
           aPPl = Pt2dr
	          (
		      (aKX+0.5+aMul*NRrandC())*aPtPas.x,
		      (aKY+0.5+aMul*NRrandC())*aPtPas.y
                  );
           // std::cout  << aKX << " " << aKY << " " << aNb << " "<< aPtNbXY << "\n";
	   // std::cout << aPtPas << "\n";
       }
       else
       {
          aPPl = Pt2dr(aSz.x*NRrandom3(),aSz.y*NRrandom3());
       }

       
       // std::cout << aPPl << "\n";
       double aZ = aTMnt.getr(aPPl);

       aZ = aGBI.Origine().z + aZ *  aGBI.Step().z;
       aPPl = Pt2dr
              (
	           aGBI.Origine().x+aPPl.x*aGBI.Step().x,
	           aGBI.Origine().y+aPPl.y*aGBI.Step().y
	      );
       Pt3dr aPTer(aPPl.x,aPPl.y,aZ);


       if (aMasterCam)
       {
           if (aGBI.DTMIsZ().Val())
              aPTer = aMasterCam->ImEtZ2Terrain(aPPl,aZ);
           else
              aPTer = aMasterCam->ImEtProf2Terrain(aPPl,aZ);
       }
       aL.push_back(aPTer);
   }
}
Пример #8
0
void Test_DBL()
{
    Pt2dr aP0(-10,-20);
    Pt2dr aP1(1500,2000);
    Pt2di aNb(10,15);

    cDistorBilin aDBL1(aP0,aP1,aNb);
    Box2dr aBoxRab1 = aDBL1.BoxRab(0.3);

   //======================================================
   // Verif interpol/extrapol de fon lineaire est exacte 
   //======================================================

    for (int aTime=0 ; aTime<10000 ; aTime++)
    {
        double aF = pow(2.0,NRrandC()*8);
        Pt2dr aPP = Pt2dr(NRrandC(),NRrandC()) * aF;
        aDBL1.InitAffine(aF,aPP);
        for (int aK=0 ; aK<10; aK++)
        {
            Pt2dr aP0 = aBoxRab1.RandomlyGenereInside();
            Pt2dr aP1 = aDBL1.Direct(aP0);
            Pt2dr aQ1 = aPP + aP0 * aF;
            double aDist = euclid(aP1,aQ1);
            if (aDist>1e-9)
            {
                ELISE_ASSERT(false,"Test_DBL Affine");
            }
        }
    }




   //============================
   // Test copy
   //============================

    for (int aK=0 ; aK<10000 ; aK++)
    {
         aDBL1.Randomize();
         cDistorBilin aDBL2 = aDBL1;
         Pt2dr aP0 = aBoxRab1.RandomlyGenereInside();
         Pt2dr aP1 = aDBL1.Direct(aP0);
         Pt2dr aP2 = aDBL2.Direct(aP0);
         double aDist = euclid(aP1,aP2);
         ELISE_ASSERT(aDist==0,"Test_DBL dist");
    }
    
   //============================
   //  V_SetScalingTranslate
   //============================

    for (int aTime=0 ; aTime<10000 ; aTime++)
    {
        double aF = pow(2.0,NRrandC()*8);
        Pt2dr aPP = Pt2dr(NRrandC(),NRrandC()) * aF;
        aDBL1.Randomize();
        cDistorBilin aDBL2 = aDBL1;
        aDBL2.V_SetScalingTranslate(aF,aPP);
        Box2dr aBoxRab2 = aDBL2.BoxRab(0.3);

        for (int aK=0 ; aK<10; aK++)
        {
            Pt2dr aP0 = aBoxRab2.RandomlyGenereInside();
            Pt2dr aP2 = aDBL2.Direct(aP0);

            Pt2dr aP1 = (aDBL1.Direct(aPP+aP0*aF)-aPP) /aF;
            double aDist = euclid(aP1 - aP2);

            ELISE_ASSERT(aDist<1e-9,"DBL-setScalingTranslate");
        }
    }

   //============================
   //  Verif Inverse
   //============================

    for (int aTime=0 ; aTime<100000 ; aTime++)
    {
        aDBL1.Randomize(0.01);

        for (int aK=0 ; aK<10; aK++)
        {
            Pt2dr aP0 = aBoxRab1.RandomlyGenereInside();
            Pt2dr aP1 = aDBL1.Direct(aP0);
            Pt2dr aP2 = aDBL1.Inverse(aP1);

            double aDist = euclid(aP0 - aP2);
            // std::cout << "D= " << aDist << "\n";

            ELISE_ASSERT(aDist<1e-5,"DBL-setScalingTranslate");
        }
   }
/*
*/


    std::cout << "DONE Test cDistorBilin\n";
}