Skip to content

Commit

Permalink
Merge pull request #246 from micmacIGN/md-MesIm_2_MMV1
Browse files Browse the repository at this point in the history
Add MMV2_MesIm_2_MMV1 cmd
  • Loading branch information
mdaakir authored Apr 22, 2024
2 parents eebaf48 + 54979ed commit 0b22bb7
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
1 change: 1 addition & 0 deletions MMVII/include/MMVII_DeclareAllCmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ extern cSpecMMVII_Appli TheSpec_TutoFormalDeriv;
extern cSpecMMVII_Appli TheSpec_ExportUndistMesIm;
extern cSpecMMVII_Appli TheSpecAppliExtractLine;
extern cSpecMMVII_Appli TheSpec_CERN_ImportClino;
extern cSpecMMVII_Appli TheSpec_MMV2_MesIm_2_MMV1;
};

#endif // _MMVII_DeclareAllCmd_H_
1 change: 1 addition & 0 deletions MMVII/src/Appli/cSpecMMVII_Appli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ std::vector<cSpecMMVII_Appli *> & cSpecMMVII_Appli::InternVecAll()
TheVecAll.push_back(&TheSpec_ExportUndistMesIm);
TheVecAll.push_back(&TheSpecAppliExtractLine);
TheVecAll.push_back(&TheSpec_CERN_ImportClino);
TheVecAll.push_back(&TheSpec_MMV2_MesIm_2_MMV1);

std::sort(TheVecAll.begin(),TheVecAll.end(),CmpCmd);
}
Expand Down
137 changes: 137 additions & 0 deletions MMVII/src/Exports/MMV2_MesIm_2_MMV1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#include "cMMVII_Appli.h"
#include "MMVII_PCSens.h"
#include "V1VII.h"

namespace MMVII
{

class cAppli_MMV2_MesIm_2_MMV1 : public cMMVII_Appli
{
public:
cAppli_MMV2_MesIm_2_MMV1(const std::vector<std::string> & aVArgs, const cSpecMMVII_Appli & aSpec);

private:
int Exe() override;
cCollecSpecArg2007 & ArgObl(cCollecSpecArg2007 & anArgObl) override;
cCollecSpecArg2007 & ArgOpt(cCollecSpecArg2007 & anArgOpt) override;

cPhotogrammetricProject mPhProj;
std::string mSpecImIn;
std::string mNameFile;
bool mShow;

};

cAppli_MMV2_MesIm_2_MMV1::cAppli_MMV2_MesIm_2_MMV1(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec) :
cMMVII_Appli (aVArgs,aSpec),
mPhProj (*this),
mShow (false)

{
}

cCollecSpecArg2007 & cAppli_MMV2_MesIm_2_MMV1::ArgObl(cCollecSpecArg2007 & anArgObl)
{
return anArgObl
<< Arg2007(mSpecImIn,"Pattern/file for images",{{eTA2007::MPatFile,"0"},{eTA2007::FileDirProj}})
<< mPhProj.DPPointsMeasures().ArgDirInMand()
<< Arg2007(mNameFile ,"Name of V1-image-measure file (\""+MMVII_NONE +"\" if none !)",{eTA2007::FileTagged})
;
}


cCollecSpecArg2007 & cAppli_MMV2_MesIm_2_MMV1::ArgOpt(cCollecSpecArg2007 & anArgOpt)
{
return anArgOpt
<< AOpt2007(mShow,"ShowD","Show details",{eTA2007::HDV})
;
}

int cAppli_MMV2_MesIm_2_MMV1::Exe()
{
mPhProj.FinishInit();

//read the image pattern
std::vector<std::string> aVecIm = VectMainSet(0);//interface to MainSet

//MicMac v1
cSetOfMesureAppuisFlottants aDico;

for (const std::string& aCImage : aVecIm)
{

cSetMesImGCP aSetMes;

//load GCPs
mPhProj.LoadGCP(aSetMes);

//load image measurements
mPhProj.LoadIm(aSetMes,aCImage);

//image measurements to export
cSetMesPtOf1Im aSetMesOut(FileOfPath(aCImage));

//MicMac v1
cMesureAppuiFlottant1Im aMAF;

for(const auto & aVMes : aSetMes.MesImInit())
{
std::string aNameImage = aVMes.NameIm();
std::vector<cMesIm1Pt> aVMesIm = aVMes.Measures();

//MicMac v1
aMAF.NameIm() = aNameImage;

for(const auto & aMes : aVMes.Measures())
{
std::string aGcpName = aMes.mNamePt;
cPt2dr aPtIm = aMes.mPt;

//MicMac v1
cOneMesureAF1I aOAF1I;
Pt2dr aPt;
aPt.x = aPtIm.x();
aPt.y = aPtIm.y();
aOAF1I.NamePt() = aGcpName;
aOAF1I.PtIm() = aPt;

if(mShow)
{
std::cout << aNameImage << "," << aGcpName << "," << aPtIm.x() << "," << aPtIm.y() << std::endl;
}

//add to the dico
aMAF.OneMesureAF1I().push_back(aOAF1I);

}


}

//append to the dico
aDico.MesureAppuiFlottant1Im().push_back(aMAF);
}

//write image measure in MicMac v1 .xml format
MakeFileXML(aDico,mNameFile);

return EXIT_SUCCESS;
}

tMMVII_UnikPApli Alloc_Test_MMV2_MesIm_2_MMV1(const std::vector<std::string> & aVArgs,const cSpecMMVII_Appli & aSpec)
{
return tMMVII_UnikPApli(new cAppli_MMV2_MesIm_2_MMV1(aVArgs,aSpec));
}

cSpecMMVII_Appli TheSpec_MMV2_MesIm_2_MMV1
(
"MMV2_MesIm_2_MMV1",
Alloc_Test_MMV2_MesIm_2_MMV1,
"Export image measurements format from MicMac v2 to MicMac v1",
{eApF::GCP},
{eApDT::GCP},
{eApDT::GCP},
__FILE__
);

}

0 comments on commit 0b22bb7

Please sign in to comment.