Skip to content

Commit

Permalink
Bundle_clino avec le bon format de fichiers
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestinHuet authored and jmmuller committed Nov 13, 2024
1 parent 24c6966 commit 7c076cf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 61 deletions.
5 changes: 1 addition & 4 deletions MMVII/src/BundleAdjustment/BundleAdjustment.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ class cBA_Clino : public cMemCheck
void readMeasures();

const cPhotogrammetricProject * mPhProj; // Photogrammetric project
const std::string mNameClino; // name of clino observations file
const std::string mFormat; // format of clino observations file
const std::vector<std::string> mPrePost; // values added before and after image names in clino observations
// file to have the same names than in initial solutions file
std::vector<cClinoMes1Cam> mVMeasures; // observations for one image and one clino
std::vector<std::string> mVNamesClino; // clino names
Expand Down Expand Up @@ -344,7 +341,7 @@ class cMMVII_BundleAdj
cBA_Topo* getTopo() { return mTopo;}

// Add clino bloc to compute relative orientation between clino and a camera
void AddClinoBloc(const std::string aNameClino, const std::string aFormat, std::vector<std::string> aPrePost);
void AddClinoBloc();
void AddClinoBloc(cBA_Clino * aBAClino);

bool AddTopo(const std::string & aTopoFilePath); // TOPO
Expand Down
62 changes: 15 additions & 47 deletions MMVII/src/BundleAdjustment/Bundle_Clino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,87 +88,55 @@ namespace MMVII

cBA_Clino::cBA_Clino
(
const cPhotogrammetricProject *aPhProj,
const std::string & aNameClino,
const std::string & aFormat,
const std::vector<std::string> & aPrePost
const cPhotogrammetricProject *aPhProj
):
mPhProj (aPhProj),
mNameClino (aNameClino),
mFormat (aFormat),
mPrePost (aPrePost),
mEqBlUK (EqClinoBloc(true,1,true)),
mEqBlUKRot (EqClinoRot(true,1,true))
{
// Read initial values of clinometers computed by ClinoInit
readMeasures();
}

cBA_Clino::cBA_Clino
(
const cPhotogrammetricProject *aPhProj
):
mPhProj (aPhProj),
mEqBlUK (EqClinoBloc(true,1,true)),
mEqBlUKRot (EqClinoRot(true,1,true))
{}


void cBA_Clino::readMeasures()
{
// Read clino observations file
cReadFilesStruct aRFS(mNameClino,mFormat,0,-1,'#');
aRFS.Read();
cSetMeasureClino aSMC = mPhProj->ReadMeasureClino() ;

// Get clino names
mVNamesClino = aRFS.VStrings().at(0);
mVNamesClino = aSMC.NamesClino();

// Initialize cameara calibration (to get after its orientation)
cPerspCamIntrCalib * aCalib = nullptr;

// For each measure
size_t aNbMeasures = aRFS.NbRead();
for (size_t aKLine=0 ; aKLine<aNbMeasures ; aKLine++)
for (auto aOneMesureClino : aSMC.SetMeasures())
{
// get image name
std::string aNameIm = aRFS.VNameIm().at(aKLine);

// If prepost is defined, add prepost before and after aNameIm
if (mPrePost.size()==2)
{
aNameIm = mPrePost[0] + aNameIm + mPrePost[1];
}

// read camera orientation if files
std::string aNameIm = aSMC.NameOfIm(aOneMesureClino);
cSensorCamPC * aCam = mPhProj->ReadCamPC(aNameIm,true,true);

if (aCam != nullptr)
{
// Get camera calibration
aCalib = aCam->InternalCalib();
// Get clino names for this measure
std::vector<std::string> aVString = aRFS.VStrings().at(aKLine);
// Get clino measures for this measure
std::vector<tREAL8> aVNum = aRFS.VNums().at(aKLine);

// Divide aVNum in clino measures and clino weights
std::vector<tREAL8> aVClino;
std::vector<tREAL8> aVWeights;
for (size_t aK = 0; aK < aVString.size(); aK++)

// Divide aVNum in clino measures and clino weights
std::vector<tREAL8> aVClino = aOneMesureClino.Angles();

std::vector<tREAL8> aDefaultVWeight;
for (size_t i = 0; i < aVClino.size(); i++)
{
aVClino.push_back(aVNum[2*aK]);
aVWeights.push_back(aVNum[2*aK+1]);
aDefaultVWeight.push_back(1.0);
}


std::vector<tREAL8> aVWeights = aOneMesureClino.VSigma().value_or(aDefaultVWeight);
// Add measure
cClinoMes1Cam aClinoMes1Cam(aCam, aVString, aVClino, aVWeights);
cClinoMes1Cam aClinoMes1Cam(aCam, mVNamesClino, aVClino, aVWeights);
mVMeasures.push_back(aClinoMes1Cam);
}
else
{
StdOut() << "Image " << aNameIm << " not found" << std::endl;
}

}

// If no measures, return an error
Expand Down
12 changes: 4 additions & 8 deletions MMVII/src/BundleAdjustment/cAppliBundAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ class cAppliBundlAdj : public cMMVII_Appli
std::vector<double> mBRSigma; // RIGIDBLOC
std::vector<double> mBRSigma_Rat; // RIGIDBLOC
std::vector<std::string> mParamRefOri; // Force Poses to be +- equals to this reference
std::string mNameClino; ///< Pattern of xml file // CLINOBLOC
std::string mFormat; // CLINOBLOC
std::vector<std::string> mPrePost; // CLINOBLOC

int mNbIter;

Expand Down Expand Up @@ -161,9 +158,7 @@ cCollecSpecArg2007 & cAppliBundlAdj::ArgOpt(cCollecSpecArg2007 & anArgOpt)
<< AOpt2007(mLVM,"LVM","Levenberg–Marquardt parameter (to have better conditioning of least squares)",{eTA2007::HDV})
<< AOpt2007(mBRSigma,"BRW","Bloc Rigid Weighting [SigmaCenter,SigmaRot]",{{eTA2007::ISizeV,"[2,2]"}}) // RIGIDBLOC
<< AOpt2007(mBRSigma_Rat,"BRW_Rat","Rattachment fo Bloc Rigid Weighting [SigmaCenter,SigmaRot]",{{eTA2007::ISizeV,"[2,2]"}}) // RIGIDBLOC
<< AOpt2007(mNameClino, "NameClino", "Name of inclination file") // ,{eTA2007::FileDirProj})
<< AOpt2007(mFormat, "Format", "Format of file like ISFSSFSSFSSFS ")
<< AOpt2007(mPrePost,"PrePost","[Prefix,PostFix] to compute image name",{{eTA2007::ISizeV,"[2,2]"}})
<< mPhProj.DPMeasuresClino().ArgDirInOpt()

<< AOpt2007(mParamRefOri,"RefOri","Reference orientation [Ori,SimgaTr,SigmaRot?,PatApply?]",{{eTA2007::ISizeV,"[2,4]"}})
<< AOpt2007(mVSharedIP,"SharedIP","Shared intrinc parmaters [Pat1Cam,Pat1Par,Pat2Cam...] ",{{eTA2007::ISizeV,"[2,20]"}}) // ]]
Expand Down Expand Up @@ -324,9 +319,10 @@ int cAppliBundlAdj::Exe()
mBA.AddCamBlocRig(aNameIm);
}

if (IsInit(&mNameClino))

if (mPhProj.DPClinoMeters().DirInIsInit())
{
mBA.AddClinoBloc(mNameClino, mFormat, mPrePost);
mBA.AddClinoBloc();
}

if (IsInit(&mPatFrosenClino))
Expand Down
4 changes: 2 additions & 2 deletions MMVII/src/BundleAdjustment/cMMVII_BundleAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,10 @@ void cMMVII_BundleAdj::SaveBlocRigid()
/* Clino Bloc */
/* ---------------------------------------- */

void cMMVII_BundleAdj::AddClinoBloc(const std::string aNameClino, const std::string aFormat, std::vector<std::string> aPrePost)
void cMMVII_BundleAdj::AddClinoBloc()
{
AssertPhpAndPhaseAdd();
mBlClino = new cBA_Clino(mPhProj, aNameClino, aFormat, aPrePost);
mBlClino = new cBA_Clino(mPhProj);

mBlClino->AddToSys(mSetIntervUK);
}
Expand Down
1 change: 1 addition & 0 deletions MMVII/src/ImportFormat/ImportClino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ cOneMesureClino::cOneMesureClino() :

const std::string & cOneMesureClino::Ident() const {return mIdent; }
const std::vector<tREAL8> & cOneMesureClino::Angles() const {return mAngles;}
const std::optional<std::vector<tREAL8>> & cOneMesureClino::VSigma() const {return mVSigma;}

cOneMesureClino::cOneMesureClino
(
Expand Down

0 comments on commit 7c076cf

Please sign in to comment.