Skip to content

Commit 236ee48

Browse files
author
deseilligny
committed
Cern wire dist in ReportBlock
1 parent 2ef53e7 commit 236ee48

File tree

12 files changed

+416
-79
lines changed

12 files changed

+416
-79
lines changed

MMVII/include/MMVII_Geom2D.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ template <class Type> class cHomot2D
164164
/// evaluate from a vec [TrX,TrY,ScX,ScY], typycally result of mean square
165165
static tTypeMap FromParam(const cDenseVect<Type> &);
166166
/// compute the vector used in least square equation
167+
static void ToEqParam(tPt & aRHS,std::vector<cDenseVect<Type>>&,const tPt &In,const tPt & Out);
168+
/// Old interface
167169
static void ToEqParam(tPt & aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt &In,const tPt & Out);
170+
168171
/// compute by least square the mapping such that Hom(PIn[aK]) = POut[aK]
169172
static tTypeMap StdGlobEstimate(tCRVPts aVIn,tCRVPts aVOut,Type * aRes2=nullptr,tCPVVals aVWeight=nullptr);
170173
/// compute by ransac the map minizing Sum |Map(VIn[K])-VOut[K]|
@@ -237,8 +240,10 @@ template <class Type> class cSim2D
237240

238241
/// evaluate from a vec [TrX,TrY,ScX,ScY], typycally result of mean square
239242
static tTypeMap FromParam(const cDenseVect<Type> &);
240-
/// compute the vectors and constants used in least square equation
241-
static void ToEqParam(tPt& aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt & aPtIn,const tPt & aPtOut);
243+
/// compute the vector used in least square equation
244+
static void ToEqParam(tPt & aRHS,std::vector<cDenseVect<Type>>&,const tPt &In,const tPt & Out);
245+
/// Old interface
246+
static void ToEqParam(tPt & aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt &In,const tPt & Out);
242247
/// Degree of freedoom
243248

244249

@@ -319,8 +324,10 @@ template <class Type> class cRot2D
319324

320325
/// evaluate from a vec [TrX,TrY,ScX,ScY], typycally result of mean square
321326
static tTypeMap FromParam(const cDenseVect<Type> &);
322-
/// compute the vectors and constants used in least square equation
323-
static void ToEqParam(tPt& aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt & aPtIn,const tPt & aPtOut);
327+
/// compute the vector used in least square equation
328+
static void ToEqParam(tPt & aRHS,std::vector<cDenseVect<Type>>&,const tPt &In,const tPt & Out);
329+
/// Old interface
330+
static void ToEqParam(tPt & aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt &In,const tPt & Out);
324331

325332
/// Refine an existing solution using least square
326333
tTypeMap LeastSquareRefine(tCRVPts aVIn,tCRVPts aVOut,Type * aRes2=nullptr,tCPVVals=nullptr)const;
@@ -398,8 +405,10 @@ template <class Type> class cAffin2D
398405

399406
/// evaluate from a vec [TrX,TrY,ScX,ScY], typycally result of mean square
400407
static tTypeMap FromParam(const cDenseVect<Type> &);
401-
/// compute the vectors and constants used in least square equation
402-
static void ToEqParam(tPt& aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt & aPtIn,const tPt & aPtOut);
408+
/// compute the vector used in least square equation
409+
static void ToEqParam(tPt & aRHS,std::vector<cDenseVect<Type>>&,const tPt &In,const tPt & Out);
410+
/// Old interface
411+
static void ToEqParam(tPt & aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt &In,const tPt & Out);
403412
/// compute with minimal number of samples
404413
static tTypeMap FromMinimalSamples(const tTabMin&,const tTabMin&);
405414
/// Affity transforming a triangle in another ~ FromMinimalSamples, just interface
@@ -468,6 +477,8 @@ template <class Type> class cHomogr2D
468477
inline tPt Value(const tPt & aP) const {return tPt(S(mHX,aP),S(mHY,aP)) / S(mHZ,aP);}
469478
inline tPt Inverse(const tPt & aP) const {return tPt(S(mIHX,aP),S(mIHY,aP)) / S(mIHZ,aP);}
470479
/// compute the vector used in least square equation
480+
static void ToEqParam(tPt & aRHS,std::vector<cDenseVect<Type>>&,const tPt &In,const tPt & Out);
481+
/// Old interface
471482
static void ToEqParam(tPt & aRHS,cDenseVect<Type>&,cDenseVect<Type> &,const tPt &In,const tPt & Out);
472483
/// Creat an homotethy from 4 example
473484
static tTypeMap FromMinimalSamples(const tTabMin&,const tTabMin&);

MMVII/include/MMVII_Geom3D.h

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,16 @@ template <class Type> class cRotation3D
9292
{
9393
public :
9494
static constexpr int TheDim=3;
95+
static constexpr int NbDOF = 3;
96+
static constexpr int NbPtsMin = 2; // != NbDOF/TheDim
97+
9598
typedef cPtxd<Type,3> tPt;
9699
typedef Type tTypeElem;
97100
typedef cRotation3D<Type> tTypeMap;
98101
typedef cRotation3D<Type> tTypeMapInv;
99-
static int NbDOF() {return 3;}
102+
typedef std::vector<tPt> tVPts;
103+
typedef const tVPts& tCRVPts;
104+
typedef tPt tTabMin[NbPtsMin]; // Used for estimate with min number of point=> for ransac
100105

101106
/// Create a "dummy" rotation, initialized with null matrix (to force problem if not init later)
102107
cRotation3D();
@@ -223,15 +228,25 @@ template <class Type> class cIsometry3D
223228
{
224229
public :
225230
static constexpr int TheDim=3;
231+
static constexpr int NbDOF= 6;
232+
static constexpr int NbPtsMin = 3; // != NbDOF/TheDim
233+
234+
226235
typedef cPtxd<Type,3> tPt;
227236
typedef cRotation3D<Type> tRot;
228237
typedef cPtxd<Type,2> tPt2;
229238
typedef cTriangle<Type,3> tTri;
230239
typedef cTriangle<Type,2> tTri2d;
231240
typedef Type tTypeElem;
241+
typedef std::vector<tPt> tVPts;
242+
typedef const tVPts& tCRVPts;
243+
typedef std::vector<Type> tVVals;
244+
typedef const tVVals * tCPVVals;
245+
246+
typedef tPt tTabMin[NbPtsMin]; // Used for estimate with min number of point=> for ransac
247+
232248
typedef cIsometry3D<Type> tTypeMap;
233249
typedef cIsometry3D<Type> tTypeMapInv;
234-
static int NbDOF() {return 6;}
235250

236251
/// Default constructor is only provided for serialization, it initialize with dummy stuff
237252
cIsometry3D();
@@ -247,6 +262,22 @@ template <class Type> class cIsometry3D
247262
/// Idem but dont normalize to unity
248263
Type DistPose(const tTypeMap & aIsom2,const Type & aWTr) const;
249264

265+
/// Estimate using ransac
266+
static tTypeMap RansacL1Estimate(tCRVPts aVIn,tCRVPts aVOut,int aNbTest);
267+
/// Estimate from 3 point , interface to "FromTriOut" for "RansacL1Estimate"
268+
static tTypeMap FromMinimalSamples(const tTabMin&,const tTabMin&);
269+
/// Basic Value(aPIn) - aPOUt
270+
tPt DiffInOut(const tPt & aPIn,const tPt & aPOUt) const;
271+
/// compute the vector used in least square equation
272+
static void ToEqParam(tPt & aRHS,std::vector<cDenseVect<Type>>&,const tPt &In,const tPt & Out);
273+
/// evaluate from a vec [TrX,TrY,ScX,ScY], typycally result of mean square
274+
static tTypeMap FromParam(const cDenseVect<Type> &);
275+
///
276+
tTypeMap LeastSquareRefine(tCRVPts aVIn,tCRVPts aVOut,Type * aRes2=nullptr,tCPVVals=nullptr)const;
277+
278+
279+
280+
250281
/// Return Isometrie with given Rot such I(PTin) = I(PTout)
251282
static cIsometry3D<Type> FromRotAndInOut(const tRot &,const tPt& aPtIn,const tPt& aPtOut );
252283
/// Return Isome such thqt I(InJ) = OutK ; In(InJJp1) // OutKKp1 ; In(Norm0) = NormOut
@@ -290,13 +321,18 @@ template <class Type> class cSimilitud3D
290321
{
291322
public :
292323
static constexpr int TheDim=3;
324+
static constexpr int NbDOF=7;
325+
static constexpr int NbPtsMin = 3; // == NbDOF/TheDim
326+
293327
typedef cPtxd<Type,3> tPt;
294328
typedef cPtxd<Type,2> tPt2;
295329
typedef cTriangle<Type,3> tTri;
296330
typedef Type tTypeElem;
331+
typedef std::vector<tPt> tVPts;
332+
typedef const tVPts& tCRVPts;
333+
typedef tPt tTabMin[NbPtsMin]; // Used for estimate with min number of point=> for ransac
297334
typedef cSimilitud3D<Type> tTypeMap;
298335
typedef cSimilitud3D<Type> tTypeMapInv;
299-
static int NbDOF() {return 7;}
300336

301337

302338
cSimilitud3D(const Type & aScale,const tPt& aTr,const cRotation3D<Type> &);

MMVII/include/MMVII_MeasuresIm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ class cSetMesGnd3D : public cMemCheck
193193

194194
const std::vector<cMes1Gnd3D> & Measures() const; ///< Accessor
195195
static const std::string ThePrefixFiles;
196+
// return null ptr if not found
197+
const cMes1Gnd3D * GetAdrMeasureOfNamePt(const std::string& aName,bool SVP=false) const;
198+
const cMes1Gnd3D & GetMeasureOfNamePt(const std::string& aName) const;
196199

197200
std::list<std::string> ListOfNames() const;
198201
std::map<std::string, cSetMesGnd3D> SplitPerOutDir(const std::string &aDefaultOutName="") const; // default out name for measures without cMes3DDirInfo

MMVII/src/BundleAdjustment/Bundle_BlocRig.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ cBA_BlocRig::cBA_BlocRig
1818
mSigmaRat (aSigmaRat),
1919
mEqRatt (aSigmaRat.empty() ? nullptr : EqBlocRig_RatE(true,1,true))
2020
{
21+
if (mBlocs.empty())
22+
{
23+
// is the user enter a non existing bloc, we arrive here with a directory empty, probably an error
24+
MMVII_UnclasseUsEr("No bloc found in rgid bloc");
25+
}
2126
// push the weigth for the 3 equation on centers
2227
for (int aK=0 ; aK<3 ; aK++)
2328
{

MMVII/src/Geom2D/GeomsBase2D.cpp

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,27 @@ template <class TypeMap>
229229
const tVVals* aVW
230230
)
231231
{
232+
// StdOut() << "cMapEstimate<TypeMap>::LeasSqEstimatecMapEstimate<TypeMap>::LeasSqEstimatecMapEstimate<TypeMap>::LeasSqEstimate\n";
232233
CheckInOut(aVIn,aVOut);
233234

234235
cLeasSqtAA<tTypeElem> aSys(TypeMap::NbDOF);
236+
std::vector<cDenseVect<tTypeElem>> aVV;
237+
for (int aDim=0; aDim<TypeMap::TheDim ; aDim++)
238+
aVV.push_back( cDenseVect<tTypeElem> (TypeMap::NbDOF));
239+
240+
241+
for (int aK=0; aK<int(aVIn.size()) ; aK++)
242+
{
243+
tPt aRHS;
244+
TypeMap::ToEqParam(aRHS,aVV,aVIn[aK],aVOut[aK]);
245+
tTypeElem aWeight = aVW ? (aVW->at(aK)) : 1.0;
246+
for (int aDim=0 ; aDim<TypeMap::TheDim ; aDim++)
247+
aSys.PublicAddObservation(aWeight,aVV.at(aDim),aRHS[aDim]);
248+
}
249+
250+
/*
235251
cDenseVect<tTypeElem> aVX(TypeMap::NbDOF);
236252
cDenseVect<tTypeElem> aVY(TypeMap::NbDOF);
237-
238253
for (int aK=0; aK<int(aVIn.size()) ; aK++)
239254
{
240255
tPt aRHS;
@@ -243,6 +258,7 @@ template <class TypeMap>
243258
aSys.PublicAddObservation(aWeight,aVX,aRHS.x());
244259
aSys.PublicAddObservation(aWeight,aVY,aRHS.y());
245260
}
261+
*/
246262
cDenseVect<tTypeElem> aSol = aSys.PublicSolve();
247263
TypeMap aMap = TypeMap::FromParam(aSol);
248264

@@ -402,7 +418,15 @@ template <class Type> cHomot2D<Type> cHomot2D<Type>::FromParam(const cDenseVect
402418
);
403419
}
404420

405-
template <class Type> void cHomot2D<Type>::ToEqParam(tPt& aRHS,cDenseVect<Type>& aVX,cDenseVect<Type> & aVY,const tPt & aPIn,const tPt & aPOut)
421+
template <class Type>
422+
void cHomot2D<Type>::ToEqParam(tPt& aRHS,std::vector<cDenseVect<Type>>& aVXY,const tPt & aPIn,const tPt & aPOut)
423+
{
424+
ToEqParam(aRHS,aVXY.at(0),aVXY.at(1),aPIn,aPOut);
425+
}
426+
427+
428+
template <class Type>
429+
void cHomot2D<Type>::ToEqParam(tPt& aRHS,cDenseVect<Type>& aVX,cDenseVect<Type> & aVY,const tPt & aPIn,const tPt & aPOut)
406430
{
407431
// param = trx try scale
408432
// XOut = 1*trx + 0*try + scale * XIN
@@ -527,6 +551,12 @@ template <class Type> cSim2D<Type> cSim2D<Type>::FromParam(const cDenseVect<Typ
527551
);
528552
}
529553

554+
template <class Type>
555+
void cSim2D<Type>::ToEqParam(tPt& aRHS,std::vector<cDenseVect<Type>>& aVXY,const tPt & aPIn,const tPt & aPOut)
556+
{
557+
ToEqParam(aRHS,aVXY.at(0),aVXY.at(1),aPIn,aPOut);
558+
}
559+
530560
template <class Type> void cSim2D<Type>::ToEqParam(tPt& aRHS,cDenseVect<Type>& aVX,cDenseVect<Type> & aVY,const tPt & aPIn,const tPt & aPOut)
531561
{
532562
// param = trx try scx scy
@@ -592,6 +622,12 @@ template <class Type> cRot2D<Type> cRot2D<Type>::FromParam(const cDenseVect<Typ
592622
);
593623
}
594624

625+
template <class Type>
626+
void cRot2D<Type>::ToEqParam(tPt& aRHS,std::vector<cDenseVect<Type>>& aVXY,const tPt & aPIn,const tPt & aPOut)
627+
{
628+
ToEqParam(aRHS,aVXY.at(0),aVXY.at(1),aPIn,aPOut);
629+
}
630+
595631
template <class Type> void cRot2D<Type>::ToEqParam(tPt& aRHS,cDenseVect<Type>& aVX,cDenseVect<Type> & aVY,const tPt & aPIn,const tPt & aPOut)
596632
{
597633
// param = trx try scx scy
@@ -810,6 +846,11 @@ template <class Type> cAffin2D<Type> cAffin2D<Type>::FromParam(const cDenseVect
810846
);
811847
}
812848

849+
template <class Type>
850+
void cAffin2D<Type>::ToEqParam(tPt& aRHS,std::vector<cDenseVect<Type>>& aVXY,const tPt & aPIn,const tPt & aPOut)
851+
{
852+
ToEqParam(aRHS,aVXY.at(0),aVXY.at(1),aPIn,aPOut);
853+
}
813854

814855
template <class Type> void cAffin2D<Type>::ToEqParam(tPt& aRHS,cDenseVect<Type>& aVX,cDenseVect<Type> & aVY,const tPt & aPIn,const tPt & aPOut)
815856
{
@@ -959,6 +1000,11 @@ template <class Type> cHomogr2D<Type> cHomogr2D<Type>::FromMinimalSamples(const
9591000
return FromParam(aSol);
9601001
}
9611002

1003+
template <class Type>
1004+
void cHomogr2D<Type>::ToEqParam(tPt& aRHS,std::vector<cDenseVect<Type>>& aVXY,const tPt & aPIn,const tPt & aPOut)
1005+
{
1006+
ToEqParam(aRHS,aVXY.at(0),aVXY.at(1),aPIn,aPOut);
1007+
}
9621008

9631009
template <class Type> void cHomogr2D<Type>::ToEqParam
9641010
(
@@ -1358,5 +1404,19 @@ MACRO_INSTATIATE_GEOM2D(tREAL16)
13581404

13591405
template int DbleAreaPolygOriented(const std::vector<cPtxd<int,2>> & aPolyg);
13601406

1407+
//=====================================================================================================================
1408+
1409+
template <class Type> cIsometry3D<Type> cIsometry3D<Type>::RansacL1Estimate(tCRVPts aVIn,tCRVPts aVOut,int aNbTest)
1410+
{
1411+
return cMapEstimate<cIsometry3D<Type>>::RansacL1Estimate(aVIn,aVOut,aNbTest);
1412+
}
1413+
template tPoseR tPoseR::RansacL1Estimate(tCRVPts aVIn,tCRVPts aVOut,int aNbTest);
1414+
1415+
template <class Type>
1416+
cIsometry3D<Type> cIsometry3D<Type>::LeastSquareRefine(tCRVPts aVIn,tCRVPts aVOut,Type * aRes2,tCPVVals aVW)const
1417+
{
1418+
return cMapEstimate<cIsometry3D<Type>>::LeastSquareRefine(*this,aVIn,aVOut,aRes2,aVW);
1419+
}
1420+
template tPoseR tPoseR::LeastSquareRefine(tCRVPts aVIn,tCRVPts aVOut,tTypeElem * aRes2,tCPVVals aVW) const;
13611421

13621422
};

0 commit comments

Comments
 (0)