Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/micmacIGN/micmac
Browse files Browse the repository at this point in the history
  • Loading branch information
erupnik committed Jan 18, 2024
2 parents e7c095f + a54fa66 commit de006f2
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 22 deletions.
9 changes: 9 additions & 0 deletions MMVII/MMVII-RessourceDir/CameraDataBase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
<NbPixels>6000 4000</NbPixels>
</V>
</Pair>
<Pair>
<K>"NIKON D3X"</K>
<V>
<Name>"NIKON D3X"</Name>
<SzPix_micron>5.95 5.95 </SzPix_micron>
<SzSensor_mm>36 24</SzSensor_mm> <!-- 35.9 24.0 in spec => non square pixel -->
<NbPixels>6048 4032</NbPixels>
</V>
</Pair>
</CamDataBase>
</Data>
</Root>
50 changes: 50 additions & 0 deletions MMVII/include/MMVII_2Include_Serial_Tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,56 @@ template <class Type> void AddOptData(const cAuxAr2007 & anAux,const std::string
}
}

template <class Type, size_t size> void AddOptTabData(const cAuxAr2007 & anAux,const std::string & aTag0,std::optional<cArray<Type, size>> & aL)
{
// put the tag as <Opt::Tag0>,
// Not mandatory, but optionality being an important feature I thought usefull to see it in XML file
// put it
std::string aTagOpt;
const std::string * anAdrTag = & aTag0;
if (anAux.Tagged())
{
aTagOpt = "Opt:" + aTag0;
anAdrTag = & aTagOpt;
}

// In input mode, we must decide if the value is present
if (anAux.Input())
{
// The archive knows if the object is present
if (anAux.NbNextOptionnal(*anAdrTag))
{
// If yes read it and initialize optional value
cArray<Type, size> aV;
AddTabData(cAuxAr2007(*anAdrTag,anAux),aV.data(), size);
aL = aV;
}
// If no just put it initilized
else
aL = std::nullopt;
return;
}

// Now in writing mode
int aNb = aL.has_value() ? 1 : 0;
// Tagged format (xml) is a special case
if (anAux.Tagged())
{
// If the value exist put it normally else do nothing (the absence of tag will be analysed at reading)
if (aNb)
AddTabData(cAuxAr2007(*anAdrTag,anAux),aL->data(), size);
}
else
{
// Indicate if the value is present and if yes put it
AddData(anAux,aNb);
anAux.Ar().Separator();
if (aNb)
AddTabData(anAux,aL->data(), size);
}
}


/// Pointer serialisation, make the assumption that pointer are valide (i.e null or dynamically allocated)
template <class Type> void OnePtrAddData(const cAuxAr2007 & anAux,Type * & aL)
{
Expand Down
5 changes: 3 additions & 2 deletions MMVII/include/MMVII_MeasuresIm.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ class cMes1GCP
public :
cMes1GCP(const cPt3dr & aPt,const std::string & aNamePt,tREAL4 aSigma);
cMes1GCP();

bool isFree() const {return !mOptSigma2;}
cPt3dr mPt;
std::string mNamePt;
static constexpr int IndXX = 0;
static constexpr int IndYY = 3;
static constexpr int IndZZ = 5;

tREAL4 mSigma2[6]; // xx xy xz yy yz zz
std::optional<cArray<tREAL4,6> > mOptSigma2; // xx xy xz yy yz zz
};

/** A set of cMes1GCP */
Expand Down Expand Up @@ -212,6 +212,7 @@ class cSetMesImGCP : public cMemCheck
std::vector<cMes1GCP> & MesGCP() ; ///< Accessor
const std::vector<cMultipleImPt> & MesImOfPt() const ; ///< Accessor
const std::vector<cSensorImage*> & VSens() const ; ///< Accessor
const std::vector<cSetMesPtOf1Im> & MesImInit() const; ///< Accessor

tREAL8 AvgSqResidual() const;

Expand Down
2 changes: 1 addition & 1 deletion MMVII/include/MMVII_Stringifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void AddData(const cAuxAr2007 & anAux, tNameOCple & aVal) ; ///< for Ordered
void AddData(const cAuxAr2007 & anAux, std::map<std::string,int>& aVal) ; ///<

template <class Type,int Dim> void AddData(const cAuxAr2007 & anAux, cPtxd<Type,Dim> & aVal) ; ///<for cPt2dr
template <class Type> void AddTabData(const cAuxAr2007 & anAux, Type * aVD,int aNbVal,eTAAr aTAAr= eTAAr::eFixTabNum);
template <class Type> void AddTabData(const cAuxAr2007 & anAux, Type * aVD,size_t aNbVal,eTAAr aTAAr= eTAAr::eFixTabNum);



Expand Down
10 changes: 10 additions & 0 deletions MMVII/include/MMVII_util_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _MMVII_Util_TPL_H_

#include <algorithm>
#include <array>
#include "MMVII_enums.h"
#include "MMVII_Error.h"
#include "MMVII_nums.h"
Expand All @@ -20,6 +21,15 @@ template <class Type> class cSelector ;
template <class Type> class cDataSelector ;


/// just a std::array that is Destructible for use with std::optional
template <class T, size_t Dim> class cArray : public std::array<T,Dim>
{
public:
~cArray() {}
};



/* ============================================= */
/* */
/* cSelector */
Expand Down
1 change: 1 addition & 0 deletions MMVII/src/BundleAdjustment/BundleAdjustment.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class cMMVII_BundleAdj


void SaveBlocRigid();
void Save_newGCP();

private :

Expand Down
12 changes: 12 additions & 0 deletions MMVII/src/BundleAdjustment/Bundle_GCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ void cMMVII_BundleAdj::OneItere_OnePackGCP(const cSetMesImGCP * aSet)
}
}

if (aVMesGCP.at(aKp).isFree())
continue;
if (! aGcpUk) // case subst, we now can make schurr commpl and subst
{
if (! aGcpFix) // if GCP is not hard fix, we must add obs on ground
Expand All @@ -149,6 +151,16 @@ void cMMVII_BundleAdj::OneItere_GCP()
}
}

void cMMVII_BundleAdj::Save_newGCP()
{
if (mMesGCP && mPhProj->DPPointsMeasures().DirOutIsInit())
{
mPhProj->SaveGCP(mNewGCP.ExtractSetGCP("NewGCP"));
for (const auto & aMes1Im : mMesGCP->MesImInit())
mPhProj->SaveMeasureIm(aMes1Im);
}
}

/* ---------------------------------------- */
/* cPt3dr_UK */
/* ---------------------------------------- */
Expand Down
4 changes: 3 additions & 1 deletion MMVII/src/BundleAdjustment/cAppliBundAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ cCollecSpecArg2007 & cAppliBundlAdj::ArgOpt(cCollecSpecArg2007 & anArgOpt)
{{eTA2007::ISizeV,"[2,5]"}}
)
<< AOpt2007(mGCPFilter,"GCPFilter","Pattern to filter GCP from their name")
<< mPhProj.DPPointsMeasures().ArgDirOutOpt("GCPDirOut","Dir for output GCP")
<< AOpt2007(mTiePWeight,"TiePWeight","Tie point weighting [Sig0,SigAtt?=-1,Thrs?=-1,Exp?=1]",{{eTA2007::ISizeV,"[1,4]"}})
<< AOpt2007(mPatParamFrozCalib,"PPFzCal","Pattern for freezing internal calibration parameters")
<< AOpt2007(mPatFrosenCenters,"PatFzCenters","Pattern of images for freezing center of poses")
Expand Down Expand Up @@ -196,7 +197,7 @@ int cAppliBundlAdj::Exe()
{
mPhProj.LoadIm(aFullMesGCP,aSens->NameImage(),aSens,true);
}
cSetMesImGCP * aMesGCP = aFullMesGCP.FilterNonEmptyMeasure();
cSetMesImGCP * aMesGCP = aFullMesGCP.FilterNonEmptyMeasure(0);

cStdWeighterResidual aWeighter(mGCPW,1);
mBA.AddGCP(mGCPW.at(0),aWeighter,aMesGCP);
Expand Down Expand Up @@ -229,6 +230,7 @@ int cAppliBundlAdj::Exe()
mPhProj.CpSysIn2Out(true,true);

mBA.SaveBlocRigid(); // RIGIDBLOC
mBA.Save_newGCP();

return EXIT_SUCCESS;
}
Expand Down
7 changes: 4 additions & 3 deletions MMVII/src/MMV1/ExportMeasuresImGCPMMV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ cSetMesGCP ImportMesGCPV1(const std::string & aNameFileMesGCPV1,const std::strin
{
cMes1GCP aMesV2(ToMMVII(aMesV1.Pt()),aMesV1.NamePt(),1.0);

aMesV2.mSigma2[cMes1GCP::IndXX] = Square(aMesV1.Incertitude().x);
aMesV2.mSigma2[cMes1GCP::IndYY] = Square(aMesV1.Incertitude().y);
aMesV2.mSigma2[cMes1GCP::IndZZ] = Square(aMesV1.Incertitude().z);
aMesV2.mOptSigma2 = {0,0,0,0,0,0};
(*aMesV2.mOptSigma2)[cMes1GCP::IndXX] = Square(aMesV1.Incertitude().x);
(*aMesV2.mOptSigma2)[cMes1GCP::IndYY] = Square(aMesV1.Incertitude().y);
(*aMesV2.mOptSigma2)[cMes1GCP::IndZZ] = Square(aMesV1.Incertitude().z);

aResult.AddMeasure(aMesV2);
}
Expand Down
5 changes: 3 additions & 2 deletions MMVII/src/Matrix/cInputOutputRSNL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ template <class Type> void cSetIORSNL_SameTmp<Type>::AddOneEq(const tIO_OneEq &
mNbEq += anIO.mVals.size();
if
(
(mNbEq > mNbTmpUk) // A priori there is no use to less or equal equation, this doesnt give any constraint
&& ( mSetIndTmpUk.NbElem()== mNbTmpUk) // we are sure to have good index, because we cannot add oustide
(mNbEq >= mNbTmpUk) // A priori there is no use to less or equal equation, this doesnt give any constraint
// but useful for GCP with 3d constraints and no 2d obs
&& ( mSetIndTmpUk.NbElem()== mNbTmpUk) // we are sure to have good index, because we cannot add oustide
)
{
mOk = true;
Expand Down
2 changes: 2 additions & 0 deletions MMVII/src/Matrix/cLeasSqtAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ template <class Type>
mSetInd.MakeInvertIndex();

mNbUk = mSetInd.mVIndOcc.size();
if (mNbUk==0) return; // nothing to substitute

mNbUkTot = mNbUk + mNbTmp;

// Adjust size, initialize of mSysRed
Expand Down
11 changes: 6 additions & 5 deletions MMVII/src/Sensors/Measures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ void cSetMesImGCP::AddMes2D(const cSetMesPtOf1Im & aSetMesIm,cSensorImage* aSens
const std::vector<cMes1GCP> & cSetMesImGCP::MesGCP() const {return mMesGCP; }
const std::vector<cMultipleImPt> & cSetMesImGCP::MesImOfPt() const {return mMesImOfPt; }
const std::vector<cSensorImage*> & cSetMesImGCP::VSens() const {return mVSens;}
const std::vector<cSetMesPtOf1Im> & cSetMesImGCP::MesImInit() const {return mMesImInit;}

std::vector<cMes1GCP> & cSetMesImGCP::MesGCP() {return mMesGCP; }

Expand Down Expand Up @@ -464,11 +465,11 @@ bool cSetMesPtOf1Im::NameHasMeasure(const std::string & aN) const {return Privat
cMes1GCP::cMes1GCP(const cPt3dr & aPt,const std::string & aNamePt,tREAL4 aSigma) :
mPt (aPt),
mNamePt (aNamePt),
mSigma2 {0,0,0,0,0,0}
mOptSigma2 { {0,0,0,0,0,0} }
{
mSigma2[IndXX] = aSigma;
mSigma2[IndYY] = aSigma;
mSigma2[IndZZ] = aSigma;
(*mOptSigma2)[IndXX] = aSigma;
(*mOptSigma2)[IndYY] = aSigma;
(*mOptSigma2)[IndZZ] = aSigma;
}

cMes1GCP::cMes1GCP() :
Expand All @@ -480,7 +481,7 @@ void AddData(const cAuxAr2007 & anAux,cMes1GCP & aMes)
{
MMVII::AddData(cAuxAr2007("Name",anAux),aMes.mNamePt);
MMVII::AddData(cAuxAr2007("Pt",anAux),aMes.mPt);
AddTabData(cAuxAr2007("Sigma2",anAux),aMes.mSigma2,6);
AddOptTabData(anAux,"Sigma2",aMes.mOptSigma2);
}

/* ********************************************* */
Expand Down
14 changes: 6 additions & 8 deletions MMVII/src/Serial/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ void AddData(const cAuxAr2007 & anAux, double & aVal) {anAux.Ar().RawAddDataT
void AddData(const cAuxAr2007 & anAux, std::string & aVal) {anAux.Ar().RawAddDataTerm(aVal); }
void AddData(const cAuxAr2007 & anAux, cRawData4Serial & aVal) {anAux.Ar().RawAddDataTerm(aVal); }


void AddData(const cAuxAr2007 & anAux, tREAL4 & aVal) { anAux.Ar().TplAddDataTermByCast(anAux,aVal,(double*)nullptr); }

void AddData(const cAuxAr2007 & anAux, tINT1 & aVal)
Expand All @@ -167,7 +166,7 @@ void AddData(const cAuxAr2007 & anAux, bool & aVal) { anAux.Ar().TplAddDat

// void AddData(const cAuxAr2007 & anAux, bool & aVal) {anAux.Ar().RawAddDataTerm(aVal); }

template <class Type> void AddTabData(const cAuxAr2007 & anAux, Type * aVD,int aNbVal,eTAAr aTAAr)
template <class Type> void AddTabData(const cAuxAr2007 & anAux, Type * aVD,size_t aNbVal,eTAAr aTAAr)
{
// A precaution, probably it work but need to test
MMVII_INTERNAL_ASSERT_always(aNbVal,"Not Sur AddTabData work for NbVal=0, check....");
Expand All @@ -179,19 +178,18 @@ template <class Type> void AddTabData(const cAuxAr2007 & anAux, Type * aVD,int

if (aNbVal)
AddData(anAux,aVD[0]);
for (int aK=1 ; aK<aNbVal ; aK++)
for (size_t aK=1 ; aK<aNbVal ; aK++)
{
anAux.Ar().Separator();
AddData(anAux,aVD[aK]);
}
anAux.Ar().OnEndTab();
}

template void AddTabData(const cAuxAr2007 & anAux, int * aVD,int aNbVal,eTAAr);
template void AddTabData(const cAuxAr2007 & anAux, size_t * aVD,int aNbVal,eTAAr);
template void AddTabData(const cAuxAr2007 & anAux, tREAL8 * aVD,int aNbVal,eTAAr);
template void AddTabData(const cAuxAr2007 & anAux, tREAL4 * aVD,int aNbVal,eTAAr);

template void AddTabData(const cAuxAr2007 & anAux, int * aVD,size_t aNbVal,eTAAr);
template void AddTabData(const cAuxAr2007 & anAux, size_t * aVD,size_t aNbVal,eTAAr);
template void AddTabData(const cAuxAr2007 & anAux, tREAL8 * aVD,size_t aNbVal,eTAAr);
template void AddTabData(const cAuxAr2007 & anAux, tREAL4 * aVD,size_t aNbVal,eTAAr);


template <class Type,int Dim> void AddData(const cAuxAr2007 & anAux, cPtxd<Type,Dim> & aPt)
Expand Down

0 comments on commit de006f2

Please sign in to comment.