Skip to content

Commit

Permalink
Merge branch 'mpd'
Browse files Browse the repository at this point in the history
  • Loading branch information
deseilligny committed Oct 23, 2024
2 parents 459625d + f3a38dc commit 2f44d94
Show file tree
Hide file tree
Showing 34 changed files with 899 additions and 139 deletions.
8 changes: 8 additions & 0 deletions MMVII/Doc/Doc2007.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
\usepackage[english]{babel}
%\usepackage[english,french]{babel}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
Expand Down Expand Up @@ -129,6 +131,9 @@
%\newcommand{\DeuxExtre}{\ensuremath{\nabla}}
\newcommand{\RefFantome}{{\bf ?2Def?}}
\newcommand{\TOMODIF}[1]{\textcolor{red}{\textbf{#1}}}

\newcommand{\TOIMPROVE}[1]{\textcolor{red}{\textbf{Possible improvement (??)} : [#1]}}

\newcommand{\PourLecteurAverti}{{\Large \bf \emph{Ce paragraphe peut
facilement \^etre omis
en premi\`ere lecture.}}}
Expand All @@ -151,6 +156,8 @@
\newcommand{\doxy}{\emph{doxygen}}
\newcommand{\MMNONE}{NONE}

%\includeonly{Methods/Line-Detection-Theory}

%---------------------------------------------
\begin{document}
\selectlanguage{english}
Expand Down Expand Up @@ -188,6 +195,7 @@ \part{Methodologies}
\include{Methods/PushBroomSensor-Theory}
\include{Methods/PoseEstimation}
\include{Methods/CodedTarget-Theory}
\include{Methods/Line-Detection-Theory}
\include{Methods/AimeDesc}
\include{Methods/TiePoints}
\include{Methods/Vrac}
Expand Down
Binary file added MMVII/Doc/Methods/ImagesFils/Crop-Hough.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/FullHough.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/GradInit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/GradNonLinear.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/ImagOri.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/MaxLocGrad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/NeighMaxLoc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/ProfilNotOk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MMVII/Doc/Methods/ImagesFils/ProfilOK.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
514 changes: 514 additions & 0 deletions MMVII/Doc/Methods/Line-Detection-Theory.tex

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions MMVII/MMVII-TestDir/Input/TestParseFile1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ this one also
# blabla
# blabla again

# here we add a line identic to already done, will ne skiped
0 Zero 3.14 0.0 0.0 1.0 2.0 3.0 0.0 0 # some comment after line
2 Two 3.14 2.0 2.0 1.0 2.0 3.0 2.0 2


Expand Down
2 changes: 2 additions & 0 deletions MMVII/include/MMVII_DeclareAllCmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ extern cSpecMMVII_Appli TheSpec_ExportUndistMesIm;
extern cSpecMMVII_Appli TheSpecAppliExtractLine;
extern cSpecMMVII_Appli TheSpec_CERN_ImportClino;
extern cSpecMMVII_Appli TheSpec_MMV2_MesIm_2_MMV1;

extern cSpecMMVII_Appli TheSpec_MergeMesImGCP;
};

#endif // _MMVII_DeclareAllCmd_H_
24 changes: 22 additions & 2 deletions MMVII/include/MMVII_ExtractLines.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class cHoughPS // : public cMemCheck

void Test(const cHoughPS & ) const;
bool Match(const cHoughPS &,bool IsDark,tREAL8 aMaxTeta,tREAL8 aDMin,tREAL8 aDMax) const;
static std::vector<cPt2di> GetMatches(std::vector<cHoughPS>& mVPS,bool IsLight,tREAL8 aMaxTeta,tREAL8 aDMin,tREAL8 aDMax);
static std::vector<std::pair<int,int>> GetMatches(const std::vector<cHoughPS>& mVPS,bool IsLight,tREAL8 aMaxTeta,tREAL8 aDMin,tREAL8 aDMax);

void UpdateSegImage(const tSeg & aNewSeg,tREAL8 aNewCumul);

Expand Down Expand Up @@ -210,6 +210,20 @@ template<class Type> void ComputeDericheAndNorm(cImGradWithN<Type> & aResGrad,co

/** Class for extracting line using gradient & hough transform*/

enum class eIsWhite
{
Yes,
No
};

enum class eIsQuick
{
Yes,
No
};

template <class Type> bool IsYes(const Type & aVal) {return aVal==Type::Yes;}

template <class Type> class cExtractLines
{
public :
Expand All @@ -221,8 +235,12 @@ template <class Type> class cExtractLines
cExtractLines(tIm anIm); ///< constructor , memorize image
~cExtractLines();

// isWhite is necessary for oriented test on max loc

/// initialize the gradient
void SetDericheGradAndMasq(tREAL8 aAlphaDerich,tREAL8 aRayMaxLoc,int aBorder,bool Show=false);
void SetSobelAndMasq(eIsWhite,tREAL8 aRayMaxLoc,int aBorder,bool Show=false);
void SetDericheAndMasq(eIsWhite,tREAL8 aAlphaDerich,tREAL8 aRayMaxLoc,int aBorder,bool Show=false);


/// Initialize the hough transform
void SetHough(const cPt2dr & aMulTetaRho,tREAL8 aSigmTeta,cPerspCamIntrCalib *,bool Accurate,bool Show=false);
Expand All @@ -241,6 +259,8 @@ template <class Type> class cExtractLines


private :
void SetGradAndMasq(eIsQuick Quick,eIsWhite isWhite,tREAL8 aRayMaxLoc,int aBorder,bool Show=false);

cPt2di mSz; ///< Size of the image
tIm mIm; ///< Memorize the image
cIm2D<tU_INT1> mImMasqCont; ///< Masq of point selected as contour
Expand Down
3 changes: 3 additions & 0 deletions MMVII/include/MMVII_MeasuresIm.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class cSetMesPtOf1Im : public cMemCheck
void AddMeasure(const cMesIm1Pt &);
void AddData(const cAuxAr2007 & anAux);


void AddSetMeasure(const cSetMesPtOf1Im &,bool SuprNone,bool OkDupl);

void ToFile(const std::string & aNameFile) const;
static std::string StdNameFileOfIm(const std::string &);
std::string StdNameFile() const;
Expand Down
4 changes: 3 additions & 1 deletion MMVII/include/MMVII_ReadFileStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ class cNRFS_ParamRead
{
public :
cNRFS_ParamRead();
cNRFS_ParamRead(int aL0,int aLast,char aComment);
cNRFS_ParamRead(int aL0,int aLast,char aComment,bool noDupL=false);

int L0() const;
int LLast() const;
char Comment() const;
bool NoDupLine() const;

void AddArgOpt(cCollecSpecArg2007 &);
private :
int mL0;
int mLLast;
char mComment;
bool mNoDupLine;
};


Expand Down
3 changes: 3 additions & 0 deletions MMVII/include/MMVII_Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ class cPhotogrammetricProject
void SaveMeasureIm(const cSetMesPtOf1Im & aSetM) const;
/// Does the measure exist
bool HasMeasureIm(const std::string & aNameIm,bool InDir=true) const;
/// Does it exist for a specific folder
bool HasMeasureImFolder(const std::string & aFolder,const std::string & aNameIma) const;

/// return from Std Dir, can be out in case of reload
cSetMesPtOf1Im LoadMeasureIm(const std::string &,bool InDir=true) const;

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 @@ -258,6 +258,7 @@ std::vector<cSpecMMVII_Appli *> & cSpecMMVII_Appli::InternVecAll()
TheVecAll.push_back(&TheSpec_CERN_ImportClino);
TheVecAll.push_back(&TheSpec_MMV2_MesIm_2_MMV1);

TheVecAll.push_back(&TheSpec_MergeMesImGCP);
std::sort(TheVecAll.begin(),TheVecAll.end(),CmpCmd);
}

Expand Down
3 changes: 2 additions & 1 deletion MMVII/src/CodedTarget/cCircTargetExtract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ cCollecSpecArg2007 & cAppliExtractCircTarget::ArgObl(cCollecSpecArg2007 & anArgO
// Standard use, we put args of cAppliParseBoxIm first
return
APBI_ArgObl(anArgObl)
<< Arg2007(mNameSpec,"Xml/Json name for bit encoding struct",{{eTA2007::XmlOfTopTag,cFullSpecifTarget::TheMainTag}})
// << Arg2007(mNameSpec,"Xml/Json name for bit encoding struct",{{eTA2007::XmlOfTopTag,cFullSpecifTarget::TheMainTag}})
<< Arg2007(mNameSpec,"Xml/Json name for bit encoding struct",{{eTA2007::FileAny}})
;
}

Expand Down
4 changes: 3 additions & 1 deletion MMVII/src/CodedTarget/cGenerateEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ cCollecSpecArg2007 & cAppliGenerateEncoding::ArgOpt(cCollecSpecArg2007 & anArgOp
<< AOpt2007(mSpec.mUseHammingCode,"UHC","Use Hamming code")
<< AOpt2007(mSpec.mPrefix,"Prefix","Prefix for output files")
<< AOpt2007(mMiror,"Mir","Unify mirro codes")
<< AOpt2007(mNameOut,"Out","Name for output file")
;
}

Expand Down Expand Up @@ -381,7 +382,8 @@ int cAppliGenerateEncoding::Exe()
+ "_Hamm" + ToStr(mSpec.mMinHammingD)
+ "_Run" + ToStr(mSpec.mMaxRunL.x()) + "_" + ToStr(mSpec.mMaxRunL.y());
}
mNameOut = mSpec.mPrefix + "_SpecEncoding." + TaggedNameDefSerial();
if (! IsInit(&mNameOut))
mNameOut = mSpec.mPrefix + "_SpecEncoding." + TaggedNameDefSerial();

// calls method in cMMVII_Appli, to show current value of params, as many transformation have been made
ShowAllParams();
Expand Down
17 changes: 11 additions & 6 deletions MMVII/src/CodedTarget/cGenerateTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ class cAppliGenCodedTarget : public cMMVII_Appli
bool mDoMarkC;
std::string mPatternDoImage;
int mNbPixBin;
std::string mNameOut;
};

eTyCodeTarget cAppliGenCodedTarget::Type() {return mBE.Specs().mType ;}
Expand All @@ -1068,7 +1069,8 @@ cCollecSpecArg2007 & cAppliGenCodedTarget::ArgObl(cCollecSpecArg2007 & anArgObl)
{
return
anArgObl
<< Arg2007(mNameBE,"Xml/Json name for bit encoding struct",{{eTA2007::XmlOfTopTag,cBitEncoding::TheMainTag}})
// << Arg2007(mNameBE,"Xml/Json name for bit encoding struct",{{eTA2007::XmlOfTopTag,cBitEncoding::TheMainTag}})
<< Arg2007(mNameBE,"Xml/Json/Dmp name for bit encoding struct",{{eTA2007::FileAny}})
;
}

Expand All @@ -1093,6 +1095,7 @@ cCollecSpecArg2007 & cAppliGenCodedTarget::ArgOpt(cCollecSpecArg2007 & anArgOpt)
<< AOpt2007(mDoMarkC,"MarkC","Mark center of bits, just for verif ",{eTA2007::HDV,eTA2007::Tuning})
<< AOpt2007(mZoomShow,"ZoomShow","Zoom to generate a high resolution check images",{eTA2007::Tuning})
<< AOpt2007(mNbPixBin,"NbPixBin","Size of binary image when printing",{eTA2007::HDV})
<< AOpt2007(mNameOut,"Out","Name for out file")
;
}

Expand Down Expand Up @@ -1136,19 +1139,21 @@ int cAppliGenCodedTarget::Exe()
}
}

std::string aName = aFullSpec.Prefix()+"_FullSpecif."+TaggedNameDefSerial();
SaveInFile(aFullSpec, aName);
// std::string aName = aFullSpec.Prefix()+"_FullSpecif."+TaggedNameDefSerial();
if (! IsInit(&mNameOut))
mNameOut = aFullSpec.Prefix()+"_FullSpecif."+ LastPostfix(mNameBE);
SaveInFile(aFullSpec, mNameOut);

if (0) // test reload
{
auto aPtr = cFullSpecifTarget::CreateFromFile(aName);
StdOut() << "NNN=" << aName << std::endl;
auto aPtr = cFullSpecifTarget::CreateFromFile(mNameOut);
StdOut() << "NNN=" << mNameOut << std::endl;
delete aPtr;
}

if (IsInit(&mZoomShow))
{
TestReloadAndShow_cFullSpecifTarget(aDirVisu,aName,mZoomShow);
TestReloadAndShow_cFullSpecifTarget(aDirVisu,mNameOut,mZoomShow);
}


Expand Down
9 changes: 5 additions & 4 deletions MMVII/src/ImagesInfoExtract/cAppliExtractLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ void cAppliExtractLine::DoOneImage(const std::string & aNameIm)

// Compute Gradient and extract max-loc in gradient direction
cAutoTimerSegm anATSDerAndMasq (mTimeSeg,"DericheAndMasq");
mExtrL->SetDericheGradAndMasq(2.0,10.0,12,mShow); // aAlphaDerich,aRayMaxLoc,aBorder
mExtrL->SetSobelAndMasq(eIsWhite::Yes,10.0,12,mShow); // aRayMaxLoc,aBorder
// mExtrL->SetDericheGradAndMasq(2.0,10.0,12,mShow); // aAlphaDerich,aRayMaxLoc,aBorder

// Compute Hough-Transform
cAutoTimerSegm anATSHough (mTimeSeg,"Hough");
Expand Down Expand Up @@ -330,11 +331,11 @@ void cAppliExtractLine::DoOneImage(const std::string & aNameIm)

{
cAutoTimerSegm anATSMatchHough (mTimeSeg,"MatchLocHough");
std::vector<cPt2di> aVMatches = cHoughPS::GetMatches(mVPS,mLineIsWhite,mParamMatch.at(0),mParamMatch.at(1),mParamMatch.at(2));
std::vector<std::pair<int,int>> aVMatches = cHoughPS::GetMatches(mVPS,mLineIsWhite,mParamMatch.at(0),mParamMatch.at(1),mParamMatch.at(2));

for (const auto aPair : aVMatches)
for (const auto & [aK1,aK2] : aVMatches)
{
mParalLines.push_back(cParalLine(mVPS.at(aPair.x()),mVPS.at(aPair.y())));
mParalLines.push_back(cParalLine(mVPS.at(aK1),mVPS.at(aK2)));
}
StdOut() << " # NBMatched " << aVMatches.size() << "\n";
SortOnCriteria
Expand Down
37 changes: 33 additions & 4 deletions MMVII/src/ImagesInfoExtract/cExtractLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,37 @@ template <class Type> void cExtractLines<Type>::SetHough
}
}

template <class Type> void cExtractLines<Type>::SetDericheGradAndMasq(tREAL8 aAlpha,tREAL8 aRay,int aBorder,bool Show)
template <class Type> void cExtractLines<Type>::SetSobelAndMasq(eIsWhite isWhite,tREAL8 aRayMaxLoc,int aBorder,bool Show)
{
// Create the data for storing gradient & init gradient
mGrad = new cImGradWithN<Type>(mIm.DIm().Sz());

mTabG->TabulateNeighMaxLocGrad(63,1.7,aRayMaxLoc); // 1.7=> maintain 8-neighboor, 63 number of direction
mGrad->SetQuickSobel(mIm.DIm(),*mTabG,2);

SetGradAndMasq(eIsQuick::Yes,isWhite, aRayMaxLoc,aBorder,Show);
}

/* The behaviour is not coherent with "SetSobelAndMasq" , to modify later probably, for now comment
template <class Type> void cExtractLines<Type>::SetDericheAndMasq(eIsWhite isWhite,tREAL8 aAlphaDerich,tREAL8 aRayMaxLoc,int aBorder,bool Show)
{
// Create the data for storing gradient & init gradient
mGrad = new cImGradWithN<Type>(mIm.DIm().Sz());
mGrad->SetDeriche(mIm.DIm(),aAlphaDerich);
SetGradAndMasq(eIsQuick::No,isWhite, aRayMaxLoc,aBorder,Show);
}
*/

template <class Type> void cExtractLines<Type>::SetGradAndMasq(eIsQuick isQuick,eIsWhite isWhite,tREAL8 aRayMaxLoc,int aBorder,bool Show)

{
// Create the data for storing gradient & init gradient
/*
mGrad = new cImGradWithN<Type>(mIm.DIm().Sz());
bool Quick = true;
bool IsWhite = true;
Expand All @@ -139,9 +165,10 @@ template <class Type> void cExtractLines<Type>::SetDericheGradAndMasq(tREAL8 aAl
{
mGrad->SetDeriche(mIm.DIm(),aAlpha);
}
*/

cRect2 aRect(mImMasqCont.DIm().Dilate(-aBorder)); // rect interior
std::vector<cPt2di> aVecNeigh = cImGradWithN<Type>::NeighborsForMaxLoc(aRay); // neigbours for compute max
std::vector<cPt2di> aVecNeigh = cImGradWithN<Type>::NeighborsForMaxLoc(aRayMaxLoc); // neigbours for compute max

// count pts & pts of contour for stat
mNbPtsCont = 0;
Expand All @@ -150,8 +177,8 @@ template <class Type> void cExtractLines<Type>::SetDericheGradAndMasq(tREAL8 aAl
for (const auto & aPix : aRect)
{
aNbPt++;
bool IsMaxLoc = Quick ?
mGrad->TabIsMaxLocDirGrad(aPix,*mTabG,IsWhite) :
bool IsMaxLoc = IsYes(isQuick) ?
mGrad->TabIsMaxLocDirGrad(aPix,*mTabG,IsYes(isWhite)) :
mGrad->IsMaxLocDirGrad(aPix,aVecNeigh,1.0) ;
if (IsMaxLoc)
{
Expand All @@ -164,6 +191,8 @@ template <class Type> void cExtractLines<Type>::SetDericheGradAndMasq(tREAL8 aAl
if (Show)
StdOut()<< " Prop Contour = " << mNbPtsCont / double(aNbPt) << "\n";
}
/*
*/

/* Generate a RGB-image :
* - background is initial image
Expand Down
6 changes: 3 additions & 3 deletions MMVII/src/ImagesInfoExtract/cHoughTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ bool cHoughPS::Match(const cHoughPS & aPS2,bool IsLight,tREAL8 aMaxTeta,tREAL8 a
}


std::vector<cPt2di> cHoughPS::GetMatches(std::vector<cHoughPS>& aVPS,bool IsLight,tREAL8 aMaxTeta,tREAL8 aDMin,tREAL8 aDMax)
std::vector<std::pair<int,int>> cHoughPS::GetMatches(const std::vector<cHoughPS>& aVPS,bool IsLight,tREAL8 aMaxTeta,tREAL8 aDMin,tREAL8 aDMax)
{
std::vector<cPt2di> aVMatches;
std::vector<std::pair<int,int>> aVMatches;
std::vector<int> aIndM( aVPS.size(),-1);
std::vector<tREAL8> aCostM( aVPS.size(),1e30);

Expand Down Expand Up @@ -341,7 +341,7 @@ std::vector<cPt2di> cHoughPS::GetMatches(std::vector<cHoughPS>& aVPS,bool IsLig
// test to get only one way && reciprocity
if ((aIndM[aK] > aK) && (aIndM[aIndM[aK]] == aK))
{
aVMatches.push_back(cPt2di(aK,aIndM[aK]));
aVMatches.push_back(std::pair<int,int>(aK,aIndM[aK]));
}
}
return aVMatches;
Expand Down
4 changes: 4 additions & 0 deletions MMVII/src/ImagesInfoExtract/cImGradWithN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ template<class Type> bool cImGradWithN<Type>::TabIsMaxLocDirGrad(const cPt2di&
cPt2di aGrad(this->mDGx->GetV(aPix),this->mDGy->GetV(aPix));
auto [aPtrVecNeigh,aIndR0] = aTabul.TabNeighMaxLocGrad(aGrad);

// first check in "small" neighboorhood if it's max lox
for (int anInd=0 ; anInd<aIndR0 ; anInd++)
{
for (auto aSign : {-1,1})
Expand All @@ -218,6 +219,7 @@ template<class Type> bool cImGradWithN<Type>::TabIsMaxLocDirGrad(const cPt2di&
}
}

// first check in "big" half neighboorhood (opposed to posible matching seg of the wire) if it's max lox
for (size_t anInd=aIndR0 ; anInd<aPtrVecNeigh->size() ; anInd++)
{
cPt2di aNeigh = aPtrVecNeigh->at(anInd) * aSignGlob;
Expand All @@ -229,6 +231,8 @@ template<class Type> bool cImGradWithN<Type>::TabIsMaxLocDirGrad(const cPt2di&
return false;
}

// then check in other big half neighboorhood , if its max loc, but only with point in same direction
// to avoid elimination by anti-paralell seg
for (size_t anInd=aIndR0 ; anInd<aPtrVecNeigh->size() ; anInd++)
{
cPt2di aNeigh = aPtrVecNeigh->at(anInd) * (-aSignGlob);
Expand Down
Loading

0 comments on commit 2f44d94

Please sign in to comment.