Skip to content

Commit

Permalink
Merge pull request #245 from micmacIGN/md-ExportUndistMesIm
Browse files Browse the repository at this point in the history
md-export undist measure images
  • Loading branch information
mdaakir authored Apr 6, 2024
2 parents 7fb7e16 + 886e4cd commit dd8fe5c
Show file tree
Hide file tree
Showing 3 changed files with 124 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 @@ -96,6 +96,7 @@ extern cSpecMMVII_Appli TheSpecTestSensor;
extern cSpecMMVII_Appli TheSpecParametrizeSensor;
extern cSpecMMVII_Appli TheSpec_TutoSerial;
extern cSpecMMVII_Appli TheSpec_TutoFormalDeriv;
extern cSpecMMVII_Appli TheSpec_ExportUndistMesIm;
extern cSpecMMVII_Appli TheSpecAppliExtractLine;
};

Expand Down
1 change: 1 addition & 0 deletions MMVII/src/Appli/cSpecMMVII_Appli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ std::vector<cSpecMMVII_Appli *> & cSpecMMVII_Appli::InternVecAll()
TheVecAll.push_back(&TheSpec_ChSysCoGCP);
TheVecAll.push_back(&TheSpec_TutoSerial);
TheVecAll.push_back(&TheSpec_TutoFormalDeriv);
TheVecAll.push_back(&TheSpec_ExportUndistMesIm);
TheVecAll.push_back(&TheSpecAppliExtractLine);

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

namespace MMVII
{

class cAppli_ExportUndistMesIm : public cMMVII_Appli
{
public:
cAppli_ExportUndistMesIm(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;
bool mShow;

};

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

{
}

cCollecSpecArg2007 & cAppli_ExportUndistMesIm::ArgObl(cCollecSpecArg2007 & anArgObl)
{
return anArgObl
<< Arg2007(mSpecImIn,"Pattern/file for images",{{eTA2007::MPatFile,"0"},{eTA2007::FileDirProj}})
<< mPhProj.DPOrient().ArgDirInMand()
<< mPhProj.DPPointsMeasures().ArgDirInMand()
;
}


cCollecSpecArg2007 & cAppli_ExportUndistMesIm::ArgOpt(cCollecSpecArg2007 & anArgOpt)
{
return anArgOpt
<< mPhProj.DPPointsMeasures().ArgDirOutOptWithDef("Undist")
<< AOpt2007(mShow,"ShowD","Show details",{eTA2007::HDV})
;
}

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

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

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

cSetMesImGCP aSetMes;

//load calibration
cPerspCamIntrCalib * aCal = mPhProj.InternalCalibFromStdName(aCImage);

//load GCPs
mPhProj.LoadGCP(aSetMes);

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

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

for(const auto & aVMes : aSetMes.MesImInit())
{
std::string aNameImage = aVMes.NameIm();

std::vector<cMesIm1Pt> aVMesIm = aVMes.Measures();

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

cPt2dr aPtIm = aMes.mPt;

cPt2dr aPtImUndist = aCal->Undist(aPtIm);

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

//fill aSetMesOut
cMesIm1Pt aMesIm1Pt(aPtImUndist,aGcpName,1.0);
aSetMesOut.AddMeasure(aMesIm1Pt);

}
}

//write in a file
mPhProj.SaveMeasureIm(aSetMesOut);
}

return EXIT_SUCCESS;
}

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

cSpecMMVII_Appli TheSpec_ExportUndistMesIm
(
"ExportUndistMesIm",
Alloc_Test_ExportUndistMesIm,
"Export image measurements of GCPs corrected from distorsion",
{eApF::Ori},
{eApDT::Ori,eApDT::GCP},
{eApDT::Console},
__FILE__
);

}

0 comments on commit dd8fe5c

Please sign in to comment.