CamStenope * cNewO_NameManager::CamOfName(const std::string & aName) { cMetaDataPhoto aMTD = cMetaDataPhoto::CreateExiv2(mDir+aName); if (mPrefOriCal =="") { std::vector<double> aPAF; double aFPix = aMTD.FocPix(); Pt2di aSzIm = aMTD.XifSzIm(); Pt2dr aPP = Pt2dr(aSzIm) / 2.0; bool IsFE; FromString(IsFE,mICNM->Assoc1To1("NKS-IsFishEye",aName,true)); std::string aNameCal = "CamF" + ToString(aFPix) +"_Sz"+ToString(aSzIm) + "FE"+ToString(IsFE); if (DicBoolFind(mDicoCam,aNameCal)) return mDicoCam[aNameCal]; CamStenope * aRes = 0; if (IsFE) { std::vector<double> aVP; std::vector<double> aVE; aVE.push_back(aFPix); aVP.push_back(aPP.x); aVP.push_back(aPP.y); aRes = new cCamLin_FishEye_10_5_5 ( false, aFPix,aPP,Pt2dr(aSzIm), aPAF, &aVP, &aVE ); } else { aRes = new CamStenopeIdeale(false,aFPix,aPP,aPAF); } aRes->SetSz(aSzIm); mDicoCam[aNameCal] = aRes; return aRes; } std::string aNC = mICNM->StdNameCalib(mPrefOriCal,aName); if (DicBoolFind(mDicoCam,aNC)) return mDicoCam[aNC]; mDicoCam[aNC] = CamOrientGenFromFile(aNC,mICNM); return mDicoCam[aNC]; }
std::list<cPoseCam *> cPackObsLiaison::ListCamInitAvecPtCom ( cPoseCam * aCam1 ) { std::set<cPoseCam *> aRes; const std::string & aName1 = aCam1->Name(); if (mIsMult) { if (DicBoolFind(mDicoMul,aName1)) { const std::vector<cOneElemLiaisonMultiple *> & aVP = mDicoMul[aName1]-> VPoses(); for (int aK=0 ; aK<int(aVP.size()) ; aK++) { if (aVP[aK]->GenPose()->RotIsInit()) { aRes.insert(aVP[aK]->GenPose()->DownCastPoseCamNN()); } } } } else { if (DicBoolFind(mDicObs,aName1)) { const std::map<std::string,cObservLiaison_1Cple *> aDic = mDicObs[aName1]; for ( std::map<std::string,cObservLiaison_1Cple *>::const_iterator iT=aDic.begin(); iT!=aDic.end(); iT++ ) { cPoseCam * aPose2 = mAppli.PoseFromName(iT->first); if (aPose2->RotIsInit()) { aRes.insert(aPose2); } } } } return std::list<cPoseCam *>(aRes.begin(),aRes.end()); }
void cAppliApero::InitOffsGps() { for (std::list<cGpsOffset>::iterator itO=mParam.GpsOffset().begin() ; itO!=mParam.GpsOffset().end() ;itO++) { ELISE_ASSERT(!DicBoolFind(mDicoOffGPS,itO->Id()),"Mutiple Base with same name"); mDicoOffGPS[itO->Id()] = new cAperoOffsetGPS(*itO,*this); } }
bool cPackObsLiaison::InitPack ( ElPackHomologue & aPack, const std::string& aNN1, const std::string& aNN2 ) { std::string aN1 = mAppli.PoseFromName(aNN1)->Name(); std::string aN2 = mAppli.PoseFromName(aNN2)->Name(); if (mIsMult) { if (DicBoolFind(mDicoMul,aN1) && mDicoMul[aN1]->InitPack(aPack,aN2)) { return false; } if (DicBoolFind(mDicoMul,aN2) && mDicoMul[aN2]->InitPack(aPack,aN1)) { aPack.SelfSwap(); return true; } } else { cObservLiaison_1Cple * aO2 = mDicObs[aN1][aN2]; if (aO2) { aPack = aO2->Pack(); return false; } aO2 = mDicObs[aN2][aN1]; if (aO2) { aPack = aO2->Pack(); aPack.SelfSwap(); return true; } } std::cout << " For : " << mId << " " << aN1 << " " << aN2 << "\n"; std::cout << " Mult " << mIsMult << "\n"; ELISE_ASSERT(false,"Cannot find liaison"); return false; }
cImplemBlockCam::cImplemBlockCam ( cAppliApero & anAppli, const cStructBlockCam aSBC, const cBlockCamera & aParamCreateBC, const std::string & anId ) : mAppli (anAppli), mSBC (aSBC), mEstimSBC (aSBC), mId (anId), mDoneIFC (false), mForCompens (false), mForRelCompens (false), mForGlobCompens (false), mKPivot (0) { const std::vector<cPoseCam*> & aVP = mAppli.VecAllPose(); // On initialise les camera for (int aKP=0 ; aKP<int(aVP.size()) ; aKP++) { cPoseCam * aPC = aVP[aKP]; std::string aNamePose = aPC->Name(); std::pair<std::string,std::string> aPair = mAppli.ICNM()->Assoc2To1(mSBC.KeyIm2TimeCam(),aNamePose,true); std::string aNameCam = aPair.second; if (! DicBoolFind(mName2Cam,aNameCam)) { cIBC_OneCam * aCam = new cIBC_OneCam(aNameCam, (int)mNum2Cam.size()); mName2Cam[aNameCam] = aCam; mNum2Cam.push_back(aCam); } } mNbCam = (int)mNum2Cam.size(); // On regroupe les images prises au meme temps for (int aKP=0 ; aKP<int(aVP.size()) ; aKP++) { cPoseCam * aPC = aVP[aKP]; std::string aNamePose = aPC->Name(); std::pair<std::string,std::string> aPair = mAppli.ICNM()->Assoc2To1(mSBC.KeyIm2TimeCam(),aNamePose,true); std::string aNameTime = aPair.first; std::string aNameCam = aPair.second; cIBC_ImsOneTime * aIms = mName2ITime[aNameTime]; if (aIms==0) { aIms = new cIBC_ImsOneTime(mNbCam,aNameTime); mName2ITime[aNameTime] = aIms; mNum2ITime.push_back(aIms); } cIBC_OneCam * aCam = mName2Cam[aNameCam]; aIms->AddPose(aPC,aCam->Num()); } mNbTime = (int)mNum2ITime.size(); std::sort(mNum2ITime.begin(),mNum2ITime.end(),TheIOTCmp); mLSHC = mSBC.LiaisonsSHC().PtrVal(); mForCompens = aParamCreateBC.UseForBundle().IsInit(); // ## mForCompens => Mettre dans StructBlockCam // On peut avoir equation / a calib et I/I+1 (pour model derive) if (mForCompens) { const cUseForBundle & aUFB = aParamCreateBC.UseForBundle().Val(); if (aUFB.GlobalBundle()) { mForGlobCompens = true; ELISE_ASSERT(false,"GlobalBundle in Rigid Block, still unsupported"); for ( std::list<cParamOrientSHC>::const_iterator itPOS=mLSHC->ParamOrientSHC().begin(); itPOS !=mLSHC->ParamOrientSHC().end(); itPOS++ ) { cIBC_OneCam * aCam = mName2Cam[itPOS->IdGrp()]; ELISE_ASSERT(aCam!=0,"Cannot get cam from IdGrp"); ELISE_ASSERT(! aCam->V0Init(),"Multiple Init For IdGrp"); // ## Creer la camera formelle initialisee en fonction de ParamOrientSHC dans aCam // LA std::cout << "xxxxxxxxxxxxxxxx CCCaaaammm " << aCam << "\n"; } } if (aUFB.RelTimeBundle()) { mForRelCompens = true; for (int aKTime=1 ; aKTime<mNbTime ; aKTime++) { cIBC_ImsOneTime * aT0 = mNum2ITime[aKTime-1]; cIBC_ImsOneTime * aT1 = mNum2ITime[aKTime]; for (int aKCam=0 ; aKCam<mNbCam ; aKCam++) { if (aKCam != mKPivot) { cPoseCam * aPcR0 = aT0->Pose(mKPivot); cPoseCam * aPcL0 = aT0->Pose(aKCam); cPoseCam * aPcR1 = aT1->Pose(mKPivot); cPoseCam * aPcL1 = aT1->Pose(aKCam); if (aPcR0 && aPcL0 && aPcR1 &&aPcL1) { cEqObsBlockCam * anEq = mAppli.SetEq().NewEqBlockCal ( aPcR0->RF(), aPcL0->RF(), aPcR1->RF(), aPcL1->RF(), false ); mVectEqRel.push_back(cAperoEqBlockTimeRel(anEq)); } } } } } // Creer les equation dans cIBC_ImsOneTime } }
void cPackObsLiaison::addFileToObservation ( const string &i_poseName1, const string &i_poseName2, const string &i_packFilename, const cBDD_PtsLiaisons &i_bd_liaison, int i_iPackObs, // index of the current cPackObsLiaison in cAppliApero->mDicoLiaisons bool i_isFirstKeySet, bool i_isReverseFile // couples inside i_packFilename are to be reversed before use ) { std::string packFullFilename = mAppli.OutputDirectory()+i_packFilename; if ( ( mAppli.NamePoseGenIsKnown(i_poseName1) && mAppli.NamePoseGenIsKnown(i_poseName2) ) && ( ( i_poseName1!=i_poseName2 ) || ( !i_bd_liaison.AutoSuprReflexif().Val() ) ) ) { cGenPoseCam * aC1 = mAppli.PoseGenFromName(i_poseName1); cGenPoseCam * aC2 = mAppli.PoseGenFromName(i_poseName2); bool OkGrp = true; if (i_bd_liaison.IdFilterSameGrp().IsInit()) OkGrp = mAppli.SameClass(i_bd_liaison.IdFilterSameGrp().Val(),*aC1,*aC2); if (OkGrp) { if (i_poseName1==i_poseName2) { std::cout << "FOR NAME POSE = " << i_poseName1 << "\n"; ELISE_ASSERT(false,"Point homologue image avec elle meme !! "); } double aPds=0; int aNbHom=0; if (mIsMult) { if (DicBoolFind(mDicoMul,i_poseName1)) { mDicoMul[i_poseName1]->AddLiaison(packFullFilename,i_poseName2,i_isFirstKeySet, i_isReverseFile ); } else { mDicoMul[i_poseName1] = new cObsLiaisonMultiple(mAppli,packFullFilename,i_poseName1,i_poseName2,i_isFirstKeySet, i_isReverseFile); } cObsLiaisonMultiple * anObs = mDicoMul[i_poseName1]; ElPackHomologue aPack; anObs->InitPack(aPack,i_poseName2); aPds = mAppli.PdsOfPackForInit(aPack,aNbHom); } else { ELISE_ASSERT(i_isFirstKeySet,"Multiple Sets in Pts non multiple"); cObservLiaison_1Cple * anObs= new cObservLiaison_1Cple(i_bd_liaison,packFullFilename,i_poseName1,i_poseName2); if (anObs->NbH() !=0) { mLObs.push_back(anObs); { cObservLiaison_1Cple * aO2 = mDicObs[i_poseName1][i_poseName2]; if (aO2 !=0) { std::cout << " For : " << mId << " " << i_poseName1 << " " << i_poseName2 <<"\n"; ELISE_ASSERT(false,"Entree multiple\n"); } } mDicObs[i_poseName1][i_poseName2] = anObs; aPds = mAppli.PdsOfPackForInit(anObs->Pack(),aNbHom); } } if (i_bd_liaison.SplitLayer().IsInit()) mAppli.SplitHomFromImageLayer(i_packFilename,i_bd_liaison.SplitLayer().Val(),i_poseName1,i_poseName2); mAppli.AddLinkCamCam(aC1,aC2); if (i_iPackObs==0) { // std::cout << "AAAAAAAAAAAAaaaa\n"; tGrApero::TSom * aS1 = mAppli.PoseGenFromName(i_poseName1)->Som(); // std::cout << "BBBBBBbbbb\n"; tGrApero::TSom * aS2 = mAppli.PoseGenFromName(i_poseName2)->Som(); // std::cout << "cCCCCC " << aS1 << " " << aS2 << "\n"; tGrApero::TArc * anArc = mAppli.Gr().arc_s1s2(*aS1,*aS2); if (!anArc) { cAttrArcPose anAttr; anArc = & mAppli.Gr().add_arc(*aS1,*aS2,anAttr); } anArc->attr().Pds() = aPds; anArc->attr().Nb() = aNbHom; // std::cout << "EEEEEEEEEE\n"; } } } }
void cAppliApero::CompileInitPoseGen(bool isPrecComp) { // Initialisation des inconnues d'orientation const tLP & aLP = mParam.PoseCameraInc(); for ( tLP::const_iterator itP = aLP.begin(); itP!=aLP.end() ; itP++) { bool isMST = itP->MEP_SPEC_MST().IsInit(); std::list<std::string> aLName; for ( std::list<std::string>::const_iterator itPat=itP->PatternName().begin(); itPat!=itP->PatternName().end(); itPat++ ) { if (itP->ByFile().Val()) { std::list<std::string> aSet = GetListFromSetSauvInFile(mDC+*itPat); std::copy(aSet.begin(),aSet.end(),std::back_inserter(aLName)); } else if (itP->ByKey().Val()) { const std::vector<string> * aSet = mICNM->Get(*itPat); std::copy(aSet->begin(),aSet->end(),std::back_inserter(aLName)); } else if (itP->ByPattern().Val()) { // std::list<std::string > aLName2Add = RegexListFileMatch(DC()+itP->Directory().Val(),*itPat,1,false); std::list<std::string > aLName2Add = mICNM->StdGetListOfFile(*itPat,1); if (aLName2Add.empty()) { std::cout << "For Pattern=["<< *itPat << "]\n"; ELISE_ASSERT(false,"Aucun match pour ce pattern de nom de pose"); } std::copy(aLName2Add.begin(),aLName2Add.end(),std::back_inserter(aLName)); } else { aLName.push_back(*itPat); } } if (itP->AutomGetImC().IsInit()) { const std::string & anId = itP->AutomGetImC().Val(); const cBDD_PtsLiaisons & aBDL = GetBDPtsLiaisonOfId(anId); ELISE_ASSERT(aBDL.KeySet().size()==1,"AddAllNameConnectedBy multiple_set"); // const std::vector<std::string> * aVNL = ICNM()->Get(aBDL.KeySet()[0]); const std::string & aKA = aBDL.KeyAssoc()[0]; std::map<std::string,double> mCpt; for (std::list<std::string>::const_iterator it1 = aLName.begin() ;it1!=aLName.end() ; it1++) mCpt[*it1] = 0; for (std::list<std::string>::const_iterator it1 = aLName.begin() ;it1!=aLName.end() ; it1++) { std::list<std::string>::const_iterator it2 = it1; it2++; for (; it2!=aLName.end() ; it2++) { std::string aNamePack = mDC+ICNM()->Assoc1To2(aKA,*it1,*it2,true); double aNb = sizeofile(aNamePack.c_str()); mCpt[*it1] += aNb; mCpt[*it2] +=aNb; } } double aBestSc = -1e9; std::string aBestN; for (std::map<std::string,double>::iterator it=mCpt.begin();it!=mCpt.end(); it++) { if (it->second > aBestSc) { aBestSc = it->second; aBestN = it->first; } } aLName.clear(); aLName.push_back(aBestN); } if (itP->AddAllNameConnectedBy().IsInit()) { cElRegex * aFilter=0; if (itP->FilterConnecBy().IsInit()) aFilter = new cElRegex(itP->FilterConnecBy().Val(),10); const std::string & anId = itP->AddAllNameConnectedBy().Val(); const cBDD_PtsLiaisons & aBDL = GetBDPtsLiaisonOfId(anId); ELISE_ASSERT(aBDL.KeySet().size()==1,"AddAllNameConnectedBy multiple_set"); const std::vector<std::string> * aVNL = ICNM()->Get(aBDL.KeySet()[0]); const std::string & aKA = aBDL.KeyAssoc()[0]; std::list<std::string> aNewL; for (int aKL=0;aKL<int(aVNL->size()) ; aKL++) { std::pair<std::string,std::string> aPair = ICNM()->Assoc2To1(aKA,(*aVNL)[aKL],false); const std::string * aNewN=0; if (BoolFind(aLName,aPair.first)) aNewN = & aPair.second; if (BoolFind(aLName,aPair.second)) aNewN = & aPair.first; if ( aNewN && (!BoolFind(aNewL,*aNewN)) && (!BoolFind(aLName,*aNewN)) ) { if((aFilter==0) || (aFilter->Match(*aNewN))) { bool isNew = isPrecComp ? (! NamePoseIsKnown(*aNewN)) : ( (NamePoseIsKnown(*aNewN)) && (! PoseFromName(*aNewN)->PreInit()) ); if (isNew) { aNewL.push_back(*aNewN); } } } } aLName = aNewL; delete aFilter; } if (itP->PatternRefuteur().IsInit()) { std::list<std::string> aNewL; for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { if (!itP->PatternRefuteur().Val()->Match(*itS)) { aNewL.push_back(*itS); } } aLName = aNewL; } if (itP->AutoRefutDupl().Val()) { std::list<std::string> aNewL; for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { if (!BoolFind(aNewL,*itS)) { aNewL.push_back(*itS); } } aLName = aNewL; } if (itP->Filter().IsInit()) { std::list<std::string> aNewL; const cNameFilter & aNF = itP->Filter().Val(); for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { if (NameFilter(mICNM,aNF,*itS)) { aNewL.push_back(*itS); } } aLName = aNewL; } if (itP->ReverseOrderName().Val()) { aLName.reverse(); } if (itP->KeyTranscriptionName().IsInit()) { std::string aKeyTr = itP->KeyTranscriptionName().Val(); std::list<std::string> aNewL; for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { aNewL.push_back(ICNM()->Assoc1To1(aKeyTr,*itS,true)); } aLName = aNewL; } if (isPrecComp) { cCompileAOI * aCAOI = itP->OptimizeAfterInit().IsInit() ? new cCompileAOI(itP->OptimizeAfterInit().Val()): 0 ; for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { std::string aNameCal = ""; if (itP->CalcNameCalib().IsInit()) { aNameCal = itP->CalcNameCalib().Val(); if (ICNM()->AssocHasKey(aNameCal)) { aNameCal = ICNM()->Assoc1To1(aNameCal,*itS,true); } } // Si les calibrations sont geres par le nouveua systeme if (!itP->CalcNameCalibAux().empty()) { ELISE_ASSERT(!itP->CalcNameCalib().IsInit(),"Choose CalcNameCalib OR CalcNameCalibAux"); aNameCal = ""; for ( std::list<cCalcNameCalibAux>::const_iterator itCAux = itP->CalcNameCalibAux().begin(); (itCAux != itP->CalcNameCalibAux().end()) && (aNameCal==""); itCAux++ ) { // std::cout << "HHHHHHHHH " << itCAux->CalcNameOnExistingTag().IsInit() << "\n"; if (itCAux->CalcNameOnExistingTag().IsInit()) { const cCalcNameOnExistingTag & aCal = itCAux->CalcNameOnExistingTag().Val(); std::string aXmlFile = DC() + ICNM()->Assoc1To1(aCal.KeyCalcFileOriExt(),*itS,true); cElXMLTree aTree (aXmlFile); bool GotTagE = (aTree.GetOneOrZero(aCal.TagExist()) !=0); bool GotTagNonE = (aTree.GetOneOrZero(aCal.TagNotExist()) !=0); // std::cout << "Auux " << aXmlFile << " " << GotTagE << " " << GotTagNonE << "\n"; if (aCal.ExigCohTags().Val()) { ELISE_ASSERT(GotTagE!=GotTagNonE,"Incoherence in CalcNameOnExistingTag"); } if (GotTagE && (!GotTagNonE)) { aNameCal = ICNM()->Assoc1To1(aCal.KeyCalcName(),*itS,true); } } if (itCAux->KeyCalcNameDef().IsInit()) { aNameCal = ICNM()->Assoc1To1(itCAux->KeyCalcNameDef().Val(),*itS,true); } } ELISE_ASSERT(aNameCal!="","Could not find satisfying CalcNameCalibAux"); } // std::string aNameCal = MatchAndReplace(anAutom,*itS,itP->CalcNameCalib()); if (DicBoolFind(mDicoPose,*itS)) { if ( itP->AutoRefutDupl().Val()) { } else { AssertEntreeDicoVide(mDicoPose,*itS,"Poses"); } } else { cPoseCam * aPC = cPoseCam::Alloc(*this,*itP,*itS,aNameCal,aCAOI); mDicoPose[*itS] = aPC; mVecPose.push_back(aPC); tGrApero::TSom & aSom = mGr.new_som(aPC); aPC->SetSom(aSom); if (! isMST) aPC->InitCpt(); for ( std::map<std::string,cLayerImage *>::iterator itLI = mMapLayers.begin(); itLI != mMapLayers.end(); itLI++ ) { itLI->second->AddLayer(*aPC); } } } } else { if ( itP->AutoRefutDupl().Val()) { std::list<std::string> aNewL; for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { cPoseCam * aPC = PoseFromNameSVP(*itS); if (aPC && ! (aPC->PreInit())) { aNewL.push_back(*itS); } } aLName = aNewL; } if (isMST) // L'init est faite "a la volee" dans MST { ConstructMST(aLName,*itP); } else { for ( std::list<std::string>::const_iterator itS=aLName.begin(); itS != aLName.end(); itS++ ) { cPoseCam * aPC = PoseFromName(*itS); if (itP->PoseFromLiaisons().IsInit()) { const std::vector<cLiaisonsInit> & aLI = itP->PoseFromLiaisons().Val().LiaisonsInit(); for ( std::vector<cLiaisonsInit>::const_iterator itL=aLI.begin(); itL!=aLI.end(); itL++ ) { cPoseCam * aPC2 = PoseFromName(aPC->CalNameFromL(*itL)); aPC->UpdateHeriteProf2Init(*aPC2); } } else { aPC->Set0Prof2Init(); // La valeur par defaut 0 de Prof2Init va tres bien } aPC->DoInitIfNow(); } } } } }