Skip to content

Commit 1ec939f

Browse files
committed
Merge branch 'master' into apib11
2 parents 3770277 + d2b2dc1 commit 1ec939f

File tree

12 files changed

+245
-80
lines changed

12 files changed

+245
-80
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ set(QT_ENABLED 0) #TODO: not sure we should keep running if WITH_QT5=1 and OpenG
191191
set(GIMMI_ENABLED 0)
192192

193193
if(${WITH_QT5})
194+
set(OpenGL_GL_PREFERENCE LEGACY)
194195
find_package(OpenGL REQUIRED)
195196

196197
if(OPENGL_FOUND)
@@ -206,6 +207,7 @@ if(${WITH_QT5})
206207
message (" WindowsSDKDir : " ${CMAKE_PREFIX_PATH} )
207208
endif()
208209

210+
add_compile_definitions(QT_NO_DEPRECATED_WARNINGS=1) # to work with both ubuntu 20.04 and 22.04...
209211
find_package(Qt5Widgets REQUIRED)
210212
find_package(Qt5Xml REQUIRED)
211213
find_package(Qt5Concurrent REQUIRED)

MMVII/Doc/Methods/PerspCamModelization.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,20 +1084,20 @@ \subsection{Intuitive analyse of dangerous case}
10841084
\end{figure}
10851085

10861086

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

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

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

11031103
is obviously a dangerous case for computing

MMVII/include/MMVII_Image2D.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ class cRGBImage
498498
static const cPt3di Yellow;
499499
static const cPt3di Magenta;
500500
static const cPt3di Cyan;
501+
static const cPt3di Orange;
501502
static const cPt3di White;
502503

503504
/// return a lut adapted to visalise label in one chanel (blue), an maximize constrat in 2 other

MMVII/include/SymbDer/SymbDer_Common.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class SYMBDER_cMemCheck
2929
#include <vector>
3030
#include <string>
3131
#include <map>
32+
#include <algorithm>
3233
// ===================== MPD error: call of overloaded ‘abs(const double&)’ is ambiguous ===============
3334
#include <math.h>
3435
#include <cmath>
@@ -119,7 +120,7 @@ class cCalculator : public SYMBDER_cMemCheck
119120
virtual ~cCalculator() {}
120121

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

124125
bool BufIsFull() const {return mNbInBuf == mSzBuf;} ///< Can we push more value ?
125126
size_t SzBuf() const {return mSzBuf;} ///< Total Number of value we can push
@@ -188,6 +189,22 @@ class cCalculator : public SYMBDER_cMemCheck
188189
mBufLineRes (mSzBuf),
189190
mBufRes ()
190191
{
192+
for (size_t i=0; i< aVNUk.size(); i++) {
193+
if (!IsValidCIdentifier(aVNUk[i])) {
194+
UserSError("Name for Unknown #" + std::to_string(i) +
195+
" is not a valid C++ identifier ('"
196+
+ aVNUk[i] + "')",
197+
mName);
198+
}
199+
}
200+
for (size_t i=0; i< aVNObs.size(); i++) {
201+
if (!IsValidCIdentifier(aVNObs[i])) {
202+
UserSError("Name for Observation #" + std::to_string(i) +
203+
" is not a valid C++ identifier ('"
204+
+ aVNObs[i] + "')",
205+
mName);
206+
}
207+
}
191208
mBufRes.reserve(mSzBuf);
192209
}
193210

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

218+
// Utility function that checks if string s is a valid C/C++ identifier
219+
bool IsValidCIdentifier(const std::string& s) const;
220+
201221
std::string mName;
202222
size_t mSzBuf; ///< Capacity of bufferirsation
203223
size_t mNbUK; ///< DimIn=number of unkown
@@ -258,6 +278,18 @@ std::vector<T> & cCalculator<T>::DoOneEval(const std::vector<TypeElem> & aVUK,co
258278
return *(this->EvalAndClear()[0]);
259279
}
260280

281+
template<typename T>
282+
bool cCalculator<T>::IsValidCIdentifier(const std::string& s) const
283+
{
284+
if (s.size() == 0)
285+
return false;
286+
if (! (std::isalpha(s[0]) || s[0] == '_'))
287+
return false;
288+
return std::all_of(s.cbegin()+1, s.cend(),[](char c) { return std::isalnum(c) || c == '_';});
289+
}
290+
291+
292+
261293
/** Specilisation for calculator opering generated code (v.s dynamic just after formula)
262294
*/
263295
template<typename T> class cCompiledCalculator : public cCalculator<T>

MMVII/include/SymbDer/SymbolicDerivatives.h

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@
1111
#endif
1212

1313

14-
// #define SYMBDER_WITH_MMVII true
15-
#define SYMBDER_WITH_EIGEN true
16-
17-
18-
#if SYMBDER_WITH_EIGEN
19-
#include "ExternalInclude/Eigen/Dense" // TODO => replace with standard eigen file
20-
#define EIGEN_ALLIGNMENT_IN_MMVII EIGEN_MAKE_ALIGNED_OPERATOR_NEW
21-
#else
22-
#define EIGEN_ALLIGNMENT_IN_MMVII
23-
#endif
24-
/*
25-
*/
2614

2715
/** \file SymbolicDerivates.h
2816
\brief File for generating symbolic derivate
@@ -91,18 +79,18 @@
9179

9280
#include "SymbDer_Common.h"
9381

94-
/*
95-
#if (SYMBDER_WITH_MMVII)
96-
#include "MMVII_Derivatives.h"
97-
#define SYMBDER_cMemCheck MMVII::cMemCheck
98-
#else //========================================================== WITH_MMVI
99-
class SYMBDER_cMemCheck
100-
{
101-
};
82+
#if SYMBDER_WITH_MMVII
83+
#define SYMBDER_WITH_EIGEN true
10284
#endif
103-
*/
10485

10586

87+
#if SYMBDER_WITH_EIGEN
88+
#include "ExternalInclude/Eigen/Dense" // TODO => replace with standard eigen file
89+
#define EIGEN_ALLIGNMENT_IN_MMVII EIGEN_MAKE_ALIGNED_OPERATOR_NEW
90+
#else
91+
#define EIGEN_ALLIGNMENT_IN_MMVII
92+
#endif
93+
10694

10795
#if (SYMBDER_WITH_MMVII)
10896
#else
@@ -572,7 +560,7 @@ template <class TypeElem> class cImplemF : public SYMBDER_cMemCheck
572560
int RecursiveRec() const;
573561

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

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

1119-
if (aName.size() == 0)
1120-
UserSError("Formula name is empty.",this->Name());
1121-
for (auto &c : aName) {
1122-
if (!std::isalnum(c) && c != '_')
1123-
UserSError("Formula name is not a valid C++ identifier: '_,a..z,A..Z,0..9' only.",this->Name());
1124-
}
1107+
if (!this->IsValidCIdentifier(this->Name()))
1108+
UserSError("Formula name is not a valid C++ identifier: '_,a..z,A..Z,0..9' only.",this->Name());
11251109
std::string aClassName = "c" + aName;
11261110
if (aTypeName.size()==0)
11271111
aTypeName = this->TypeElemName();

MMVII/src/CodedTarget/CodedTarget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class cDCT
125125
std::vector<cPt2di> mDetectedEllipse;
126126
std::vector<cPt2di> mDetectedFrame;
127127

128+
bool mRecomputed;
129+
128130
};
129131

130132
/* ============== Target spec ============= */

MMVII/src/CodedTarget/cExtractDir.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ template <class Type> cExtractDir<Type>::cExtractDir(tIm anIm,double aRhoMin,do
1414
mPtsCrown (SortedVectOfRadius(0.0,mRhoMax)) // compute vectot of neighboord sorted by norm
1515
{
1616
// compute list of circles with a step of 1 pixel, and their direction
17-
for (double aRho = aRhoMin ; aRho<aRhoMax ; aRho++)
18-
{
17+
for (double aRho = aRhoMin ; aRho<aRhoMax ; aRho++){
1918
mVCircles.push_back(GetPts_Circle(cPt2dr(0,0),aRho,true)); // true=> 8 connexity
2019
mVDIrC.push_back(tVDir());
2120

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

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

146-
if (SqN2(aDir)==0) return false; // not interesting case
147-
aDir = VUnit(aDir); // reput to unitary
144+
if (SqN2(aDir)==0) return false; // not interesting case
145+
aDir = VUnit(aDir); // reput to unitary
148146

149147
// -----------------------------------------------------------------------------------
150-
// REPRESENTATION TRANSITIONS
148+
// REPRESENTATION OF TRANSITIONS
151149
aDCT.mDetectedVectors.push_back(cPt2di(aC.x()+radius*aDir.x(), aC.y()+radius*aDir.y()));
152150
// -----------------------------------------------------------------------------------
153151

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

271269
template class cExtractDir<tREAL4>;
272270

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

275273

274+
/*
276275
double max_possible_x = std::min(aDCT.Pix().x(), anIm.DIm().Sz().x()-aDCT.Pix().x());
277276
double max_possible_y = std::min(aDCT.Pix().y(), anIm.DIm().Sz().y()-aDCT.Pix().y());
278277
double max_possible = std::min(max_possible_x, max_possible_y);
279278
double max_ray = std::min(aRayCB*0.8*size_factor, max_possible-1);
279+
*/
280280

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

283-
cExtractDir<tREAL4> anED(anIm,aRayCB*0.4, max_ray);
284-
285-
283+
cExtractDir<tREAL4> anED(anIm, ray_min, ray_max);
286284

287285
bool Ok = anED.CalcDir(aDCT);
288286

0 commit comments

Comments
 (0)