Skip to content

Commit

Permalink
Merge branch 'master' into apib11
Browse files Browse the repository at this point in the history
  • Loading branch information
meynardc committed Jan 26, 2023
2 parents 3770277 + d2b2dc1 commit 1ec939f
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 80 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ set(QT_ENABLED 0) #TODO: not sure we should keep running if WITH_QT5=1 and OpenG
set(GIMMI_ENABLED 0)

if(${WITH_QT5})
set(OpenGL_GL_PREFERENCE LEGACY)
find_package(OpenGL REQUIRED)

if(OPENGL_FOUND)
Expand All @@ -206,6 +207,7 @@ if(${WITH_QT5})
message (" WindowsSDKDir : " ${CMAKE_PREFIX_PATH} )
endif()

add_compile_definitions(QT_NO_DEPRECATED_WARNINGS=1) # to work with both ubuntu 20.04 and 22.04...
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Concurrent REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions MMVII/Doc/Methods/PerspCamModelization.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1084,20 +1084,20 @@ \subsection{Intuitive analyse of dangerous case}
\end{figure}


Let notes $\mathcal{S}^i$ the space of parametric function that are selected
Let notes $\mathcal{S}^i$ the functionnal space of parametric function that are selected
for coding functions $\mathcal{I}$, and $\mathcal{S}^h$ the space of all $H_R$ for
$R$ parsing the space of rotation.
The figure~\ref{fig:TanSpace} represent symbolicly the relation between
The figure~\ref{fig:TanSpace} represent symbolicly the possible relations between
$\mathcal{I}$, and $\mathcal{S}^h$. Note that this figure is just an
abstraction because in general $\mathcal{S}^i$ will be a high dimensionnal
vectorial space \footnote{for example, $8$ with $PP,F,k_1,\dots\alpha$}
and $\mathcal{S}^h$ is a $3$ dimensionnal manifold.

$\mathcal{S}^h$ and $ \mathcal{S}^i$ both contain identity : $Id \in \mathcal{S}^h \cap \mathcal{S}^i$.

An obvious dangerous case, symbolized by left image of
figure~\ref{fig:TanSpace}, is when $\mathcal{S}^h \subset \mathcal{S}^i$ .
An almost identicall dangerous case is a non trivial subset of $\mathcal{S}^h$
An obvious dangerous case is symbolized by left image of
figure~\ref{fig:TanSpace}, it is when $\mathcal{S}^h \subset \mathcal{S}^i$ .
An almost identicall dangerous case is when a non trivial subset of $\mathcal{S}^h$
is included in $\mathcal{S}^i$.

is obviously a dangerous case for computing
Expand Down
1 change: 1 addition & 0 deletions MMVII/include/MMVII_Image2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ class cRGBImage
static const cPt3di Yellow;
static const cPt3di Magenta;
static const cPt3di Cyan;
static const cPt3di Orange;
static const cPt3di White;

/// return a lut adapted to visalise label in one chanel (blue), an maximize constrat in 2 other
Expand Down
34 changes: 33 additions & 1 deletion MMVII/include/SymbDer/SymbDer_Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SYMBDER_cMemCheck
#include <vector>
#include <string>
#include <map>
#include <algorithm>
// ===================== MPD error: call of overloaded ‘abs(const double&)’ is ambiguous ===============
#include <math.h>
#include <cmath>
Expand Down Expand Up @@ -119,7 +120,7 @@ class cCalculator : public SYMBDER_cMemCheck
virtual ~cCalculator() {}

const std::string& Name() const { return mName;}
void SetName(const std::string& aName) const { this->mName = aName;}
void SetName(const std::string& aName) { this->mName = aName;}

bool BufIsFull() const {return mNbInBuf == mSzBuf;} ///< Can we push more value ?
size_t SzBuf() const {return mSzBuf;} ///< Total Number of value we can push
Expand Down Expand Up @@ -188,6 +189,22 @@ class cCalculator : public SYMBDER_cMemCheck
mBufLineRes (mSzBuf),
mBufRes ()
{
for (size_t i=0; i< aVNUk.size(); i++) {
if (!IsValidCIdentifier(aVNUk[i])) {
UserSError("Name for Unknown #" + std::to_string(i) +
" is not a valid C++ identifier ('"
+ aVNUk[i] + "')",
mName);
}
}
for (size_t i=0; i< aVNObs.size(); i++) {
if (!IsValidCIdentifier(aVNObs[i])) {
UserSError("Name for Observation #" + std::to_string(i) +
" is not a valid C++ identifier ('"
+ aVNObs[i] + "')",
mName);
}
}
mBufRes.reserve(mSzBuf);
}

Expand All @@ -198,6 +215,9 @@ class cCalculator : public SYMBDER_cMemCheck
// Do actual caluculus. Just store resulst in mBurLineRes. This class manages mBufRes
virtual void DoEval() = 0;

// Utility function that checks if string s is a valid C/C++ identifier
bool IsValidCIdentifier(const std::string& s) const;

std::string mName;
size_t mSzBuf; ///< Capacity of bufferirsation
size_t mNbUK; ///< DimIn=number of unkown
Expand Down Expand Up @@ -258,6 +278,18 @@ std::vector<T> & cCalculator<T>::DoOneEval(const std::vector<TypeElem> & aVUK,co
return *(this->EvalAndClear()[0]);
}

template<typename T>
bool cCalculator<T>::IsValidCIdentifier(const std::string& s) const
{
if (s.size() == 0)
return false;
if (! (std::isalpha(s[0]) || s[0] == '_'))
return false;
return std::all_of(s.cbegin()+1, s.cend(),[](char c) { return std::isalnum(c) || c == '_';});
}



/** Specilisation for calculator opering generated code (v.s dynamic just after formula)
*/
template<typename T> class cCompiledCalculator : public cCalculator<T>
Expand Down
40 changes: 12 additions & 28 deletions MMVII/include/SymbDer/SymbolicDerivatives.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@
#endif


// #define SYMBDER_WITH_MMVII true
#define SYMBDER_WITH_EIGEN true


#if SYMBDER_WITH_EIGEN
#include "ExternalInclude/Eigen/Dense" // TODO => replace with standard eigen file
#define EIGEN_ALLIGNMENT_IN_MMVII EIGEN_MAKE_ALIGNED_OPERATOR_NEW
#else
#define EIGEN_ALLIGNMENT_IN_MMVII
#endif
/*
*/

/** \file SymbolicDerivates.h
\brief File for generating symbolic derivate
Expand Down Expand Up @@ -91,18 +79,18 @@

#include "SymbDer_Common.h"

/*
#if (SYMBDER_WITH_MMVII)
#include "MMVII_Derivatives.h"
#define SYMBDER_cMemCheck MMVII::cMemCheck
#else //========================================================== WITH_MMVI
class SYMBDER_cMemCheck
{
};
#if SYMBDER_WITH_MMVII
#define SYMBDER_WITH_EIGEN true
#endif
*/


#if SYMBDER_WITH_EIGEN
#include "ExternalInclude/Eigen/Dense" // TODO => replace with standard eigen file
#define EIGEN_ALLIGNMENT_IN_MMVII EIGEN_MAKE_ALIGNED_OPERATOR_NEW
#else
#define EIGEN_ALLIGNMENT_IN_MMVII
#endif


#if (SYMBDER_WITH_MMVII)
#else
Expand Down Expand Up @@ -572,7 +560,7 @@ template <class TypeElem> class cImplemF : public SYMBDER_cMemCheck
int RecursiveRec() const;

// Every where a reference name is needed
std::string NameGlob() const { return "F" + std::to_string(NumGlob());}
std::string NameGlob() const { return "F" + std::to_string(NumGlob()) + "_";}

/// Access at global level is 4 reducing, also it is used 4 implemant in Unary & Binary
virtual const std::string & NameOperator() const = 0;
Expand Down Expand Up @@ -1116,12 +1104,8 @@ std::pair<std::string,std::string> cCoordinatorF<TypeElem>::GenCodeCommon(const
{
std::string aName = this->Name();

if (aName.size() == 0)
UserSError("Formula name is empty.",this->Name());
for (auto &c : aName) {
if (!std::isalnum(c) && c != '_')
UserSError("Formula name is not a valid C++ identifier: '_,a..z,A..Z,0..9' only.",this->Name());
}
if (!this->IsValidCIdentifier(this->Name()))
UserSError("Formula name is not a valid C++ identifier: '_,a..z,A..Z,0..9' only.",this->Name());
std::string aClassName = "c" + aName;
if (aTypeName.size()==0)
aTypeName = this->TypeElemName();
Expand Down
2 changes: 2 additions & 0 deletions MMVII/src/CodedTarget/CodedTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class cDCT
std::vector<cPt2di> mDetectedEllipse;
std::vector<cPt2di> mDetectedFrame;

bool mRecomputed;

};

/* ============== Target spec ============= */
Expand Down
34 changes: 16 additions & 18 deletions MMVII/src/CodedTarget/cExtractDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ template <class Type> cExtractDir<Type>::cExtractDir(tIm anIm,double aRhoMin,do
mPtsCrown (SortedVectOfRadius(0.0,mRhoMax)) // compute vectot of neighboord sorted by norm
{
// compute list of circles with a step of 1 pixel, and their direction
for (double aRho = aRhoMin ; aRho<aRhoMax ; aRho++)
{
for (double aRho = aRhoMin ; aRho<aRhoMax ; aRho++){
mVCircles.push_back(GetPts_Circle(cPt2dr(0,0),aRho,true)); // true=> 8 connexity
mVDIrC.push_back(tVDir());

// compute direction real that will be used for extracting axes of checkboard
for (const auto& aPix : mVCircles.back())
{
for (const auto& aPix : mVCircles.back()){
mVDIrC.back().push_back(VUnit(ToR(aPix)));
}
}
Expand Down Expand Up @@ -135,19 +133,19 @@ template <class Type> bool cExtractDir<Type>::CalcDir(tDCT & aDCT){
int aKp1 = (aKp+1)%aNbInC; // next index, circulary speaking
if (aVIsW[aKp] != aVIsW[aKp1]){ // if we have a transition

aCpt++; // one more transition
cPt2dr aP1 = aVDir[aKp]; // unitary direction before transition
cPt2dr aP2 = aVDir[aKp1]; // unitary direction after transition
double aV1 = aVVals[aKp]; // value befor trans
double aV2 = aVVals[aKp1]; // value after trans
// make a weighted average of P1/P2 corresponding to linear interpolation with threshold
cPt2dr aDir = (aP1 *(aV2-mVThrs) + aP2 * (mVThrs-aV1)) / (aV2-aV1);
aCpt++; // one more transition
cPt2dr aP1 = aVDir[aKp]; // unitary direction before transition
cPt2dr aP2 = aVDir[aKp1]; // unitary direction after transition
double aV1 = aVVals[aKp]; // value befor trans
double aV2 = aVVals[aKp1]; // value after trans
// make a weighted average of P1/P2 corresponding to linear interpolation with threshold
cPt2dr aDir = (aP1 *(aV2-mVThrs) + aP2 * (mVThrs-aV1)) / (aV2-aV1);

if (SqN2(aDir)==0) return false; // not interesting case
aDir = VUnit(aDir); // reput to unitary
if (SqN2(aDir)==0) return false; // not interesting case
aDir = VUnit(aDir); // reput to unitary

// -----------------------------------------------------------------------------------
// REPRESENTATION TRANSITIONS
// REPRESENTATION OF TRANSITIONS
aDCT.mDetectedVectors.push_back(cPt2di(aC.x()+radius*aDir.x(), aC.y()+radius*aDir.y()));
// -----------------------------------------------------------------------------------

Expand Down Expand Up @@ -270,19 +268,19 @@ template <class Type> double cExtractDir<Type>::ScoreRadiom(tDCT & aDCT)

template class cExtractDir<tREAL4>;

bool TestDirDCT(cNS_CodedTarget::cDCT & aDCT,cIm2D<tREAL4> anIm,double aRayCB, double size_factor, std::vector<cPt2di>& vec2plot){
bool TestDirDCT(cNS_CodedTarget::cDCT & aDCT, cIm2D<tREAL4> anIm, double ray_min, double ray_max, std::vector<cPt2di>& vec2plot){


/*
double max_possible_x = std::min(aDCT.Pix().x(), anIm.DIm().Sz().x()-aDCT.Pix().x());
double max_possible_y = std::min(aDCT.Pix().y(), anIm.DIm().Sz().y()-aDCT.Pix().y());
double max_possible = std::min(max_possible_x, max_possible_y);
double max_ray = std::min(aRayCB*0.8*size_factor, max_possible-1);
*/

// StdOut() << max_possible_x << " " << max_possible_y << " " << max_possible << " " << max_ray << "\n";

cExtractDir<tREAL4> anED(anIm,aRayCB*0.4, max_ray);


cExtractDir<tREAL4> anED(anIm, ray_min, ray_max);

bool Ok = anED.CalcDir(aDCT);

Expand Down
Loading

0 comments on commit 1ec939f

Please sign in to comment.