Ejemplo n.º 1
0
cDbleGrid *  cDbleGrid::StdGridPhotogram(const std::string & aNameFile,int aSzDisc)
{
   cElXMLTree aTree(aNameFile);

   if (aTree.Get("doublegrid"))
   {
      std::string aDir,aFile;
      SplitDirAndFile(aDir,aFile,aNameFile);

      cDbleGrid::cXMLMode aXmlMode;
      return new  cDbleGrid(aXmlMode,aDir,aFile);
   }

   if (aTree.Get("CalibrationInternConique"))
   {
        ElCamera * aCam = Cam_Gen_From_File(aNameFile,"CalibrationInternConique",(cInterfChantierNameManipulateur*)0);
        cDistStdFromCam aD(*aCam);

        cDbleGrid * aRes = new cDbleGrid
                              (
			          true,
				  Pt2dr(0,0),Pt2dr(aCam->Sz()),
				  Pt2dr(aSzDisc,aSzDisc),
				  aD
			      );
        delete aCam;

        return aRes;
   }



   ELISE_ASSERT(false,"cDbleGrid::StdGridPhotogram");
   return 0;
}
bool NameFilter(const std::string & aSubD,cInterfChantierNameManipulateur * aICNM,const cNameFilter & aFilter,const std::string & aName)
{
   std::string anEntete = aICNM->Dir()+ aSubD;
   std::string aFullName = anEntete + aName;

   int aSz = aFilter.SizeMinFile().Val();
   if (aSz>=0)
   {
      if (sizeofile(aFullName.c_str()) < aSz)
         return false;
   }

   if ((aFilter.Min().IsInit())&&(aFilter.Min().Val()>aName))
      return false;

   if ((aFilter.Max().IsInit())&&(aFilter.Max().Val()<aName))
      return false;


   const std::list<Pt2drSubst> & aLFoc = aFilter.FocMm();
   if (! aLFoc.empty())
   {
      
      if (!IsInIntervalle(aLFoc,GetFocalMmDefined(aFullName),true))
      {
            return false;
      }
   }
   


   for 
   (
        std::list<cKeyExistingFile>::const_iterator itKEF=aFilter.KeyExistingFile().begin();
        itKEF!=aFilter.KeyExistingFile().end();
        itKEF++
   )
   {
       bool OKGlob = itKEF->RequireForAll();
       for 
       (
            std::list<std::string>::const_iterator itKA=itKEF->KeyAssoc().begin();
            itKA!=itKEF->KeyAssoc().end();
            itKA++
       )
       {
          std::string aNameF = anEntete + aICNM->Assoc1To1(*itKA,aName,true);
          bool fExists = ELISE_fp::exist_file(aNameF);
// std::cout << "KEY-NF " << aNameF << "\n";
          bool Ok = itKEF->RequireExist() ? fExists : (!fExists);
          if (itKEF->RequireForAll())
             OKGlob = OKGlob && Ok;
          else
             OKGlob = OKGlob || Ok;
       }
   //std::cout << "KEY-NF " << aName << " " << OKGlob << "\n";
       if (!OKGlob) 
          return false;
   }


   if (aFilter.KeyLocalisation().IsInit())
   {
       const cFilterLocalisation & aKLoc = aFilter.KeyLocalisation().Val();
       std::string aNameCam = anEntete + aICNM->Assoc1To1(aKLoc.KeyAssocOrient(),aName,true);
       ElCamera * aCam = Cam_Gen_From_File(aNameCam,"OrientationConique",aICNM);
       Im2D_Bits<1> * aMasq = GetImRemanenteFromFile<Im2D_Bits<1> > (anEntete+ aKLoc.NameMasq());

       TIm2DBits<1> TM(*aMasq);

       cFileOriMnt * anOri = RemanentStdGetObjFromFile<cFileOriMnt>
                             (
                                anEntete+aKLoc.NameMTDMasq(),
                                StdGetFileXMLSpec("ParamChantierPhotogram.xml"),
                                "FileOriMnt",
                                "FileOriMnt"
                             );
       // std::cout << "ADR MASQ " << aMasq << " " << anOri << "\n";
        Pt3dr aPMnt = FromMnt(*anOri,aCam->OrigineProf());
        Pt2di aP(round_ni(aPMnt.x),round_ni(aPMnt.y));
        return ( TM.get(aP,0)==0 );
   }
   
   return true;
}
Ejemplo n.º 3
0
cOneImageOfLayer::cOneImageOfLayer
(
      cAppliApero & anAppli,
      const  cLayerImageToPose & aLIP,
      const std::string & aNameIm,
      cOneImageOfLayer *  aLayerTer
)  :
   mAppli       (anAppli), 
   mIm          (1,1),
   mTIm         (mIm),
   mVPrio       (256,255),
   mVLabOfPrio  (256,mTheNoLayer),
   mDeZoom      (aLIP.FactRed()),
   mLayerTer    (aLayerTer),
   mCam         (0),
   mGRRF        (0),
   mSysCam      (0)
{
    const cLayerTerrain * aLT = aLIP.LayerTerrain().PtrVal();
    if (aLT)
    {
       if (mLayerTer) // On dans une image en train de se "brancher" vers le terrain
       {
            mLabMin = mLayerTer->mLabMin;
            mLabMax = mLayerTer->mLabMax;
            std::string aNameCam = mAppli.DC()+ mAppli.ICNM()->Assoc1To1(aLT->KeyAssocOrImage(),aNameIm,true);
            mCam = Cam_Gen_From_File(aNameCam,aLT->TagOri().Val(),mAppli.ICNM());
            return;
       }
       else // On est en train de creer le layer terrain lui meme
       {
           std::string aNameGeoR = mAppli.DC()+ mAppli.ICNM()->Assoc1To1(aLT->KeyAssocGeoref().Val(),aNameIm,true);
           mGRRF = cGeoRefRasterFile::FromFile(aNameGeoR);
           if (aLT->ZMoyen().IsInit())
              mZMoy = aLT->ZMoyen().Val();
           else
              mZMoy = mGRRF->ZMoyen();

           mSysCam = cSysCoord::FromFile(mAppli.DC()+aLT->SysCoIm());
       }
    }
    std::string aNameRed =  mAppli.DC()+ mAppli.ICNM()->Assoc1To1(aLIP.KeyNameRed().Val(),aNameIm,true);
    if (mDeZoom==1)  
    {
        aNameRed =  mAppli.DC()+aNameIm;
    }
    if (LoadFileRed(aNameRed))
       return;

    // ON LOADE l'IMAGE REDUITE ,  INITIALISE les tailles, ALLOUE la memoire

    for (int aK=0 ; aK<int(aLIP.EtiqPrio().size()); aK++) 
    {
       mVPrio[aLIP.EtiqPrio()[aK]] = aK;
    }
    ElSetMin(mVPrio[mTheNoLayer],int(aLIP.EtiqPrio().size()));

    for (int aK=0 ; aK<256; aK++) 
    {
       mVLabOfPrio[mVPrio[aK]] = aK;
    }
    

    Im2D_U_INT1 aImZ1 = Im2D_U_INT1::FromFileStd(anAppli.DC()+aNameIm);
    Im2D_U_INT1 aImTmp = MakeImagePrio(aImZ1,mDeZoom,mDeZoom/2);


    int aFCoh = aLIP.FactCoherence().Val();
    int aSzBox =  (aFCoh>=0) ? ((aFCoh+mDeZoom-1)/mDeZoom) : 0;
    mIm = MakeImagePrio(aImTmp,1,aSzBox);
    mTIm = TIm2D<U_INT1,INT>(mIm);




    Tiff_Im::CreateFromIm(mIm,aNameRed);
    bool OkLoad = LoadFileRed(aNameRed);
    ELISE_ASSERT(OkLoad,"Incoh in cOneImageOfLayer::cOneImageOfLayer");

    std::cout << "   ==== LAB = " << mLabMin << " " << mLabMax << "\n";
}