25 #ifndef __GenSynthMatches_hh__
26 #define __GenSynthMatches_hh__
28 #include <bias_config.h>
30 #include <Base/Common/BIASpragmaStart.hh>
36 #include <Base/Image/Image.hh>
37 #include <Base/Geometry/HomgPoint2D.hh>
38 #include <Base/Geometry/HomgPoint3D.hh>
39 #include <Base/Geometry/KMatrix.hh>
40 #include <Base/Geometry/FMatrixBase.hh>
41 #include <Base/Geometry/EuclideanTransf3D.hh>
42 #include <Base/Geometry/RMatrixBase.hh>
43 #include <Base/Geometry/PMatrixBase.hh>
44 #include <Utils/Param.hh>
45 #include <Base/Math/Random.hh>
46 #include "MatchDataBase.hh"
54 #define GSM_CAM_MOTION 0x00010000
55 #define GSM_VIEWINGVOL 0x00020000
56 #define GSM_3D_POINTS 0x00040000
57 #define GSM_2D_MATCHES 0x00080000
58 #define GSM_MOVIN_TRANSF 0x00100000
59 #define GSM_MOVIN_3D_POINTS 0x00200000
60 #define GSM_FMATRIX 0x00400000
61 #define GSM_NOISE 0x00800000
63 #define GSM_RETURN_OK 0
64 #define GSM_RETURN_NO_STATIC_3D_POINTS -1
65 #define GSM_RETURN_NO_MOVING_3D_POINTS -2
66 #define GSM_RETURN_STATIC_OBJECT_NOT_VISIBLE -3
67 #define GSM_RETURN_MOVING_OBJECT_NOT_VISIBLE -4
68 #define GSM_RETURN_ERROR_HANDLING_STATIC_POINT -5
69 #define GSM_RETURN_ERROR_HANDLING_MOVING_POINT -6
87 int Create3DPoints(
bool fixed_errors =
false);
89 int CreateStatic3DPoint(
int index);
91 int CreateMoving3DPoint(
int index);
94 int CreateMatches(
bool points3D_set_by_user =
false,
95 bool fixed_errors =
false);
97 int CreateMatches(
int &index);
101 {_CreateCamMovement(fixed_error);} ;
108 _StaticPoints = points;
109 return _StaticPoints.size();
113 points = _StaticPoints;
114 return _StaticPoints.size();
118 _MovingPoints = points;
119 return _MovingPoints.size();
123 points = _MovingPoints;
124 return _MovingPoints.size();
128 res = _MovingTransform;
129 return _MovingTransform.size();
132 return *_NumMovingObjects;
136 int maxindex=1)
const;
138 int maxindex=1)
const;
141 int WriteData(std::string file)
const;
143 int ReadData(std::string file);
146 int Read(
const std::string& fname);
148 virtual int Read(std::istream& is);
151 int Write(
const std::string& fname)
const;
153 virtual int Write(std::ostream& os)
const;
157 void GetGTR(std::vector<RMatrixBase>& R)
const;
161 void GetGTC(std::vector<HomgPoint3D>& C)
const;
165 void GetGTP(std::vector<PMatrixBase>& P)
const;
168 void GetGTPoints(
int imNo, std::vector<HomgPoint2D>& p)
const;
169 void GetGTPoints(std::vector<std::vector<HomgPoint2D> >& p)
const;
172 void GetGTNormalizedPoints(
int imNo, std::vector<HomgPoint2D>& p)
const;
173 void GetGTNormalizedPoints(std::vector<std::vector<HomgPoint2D> >& p)
const;
176 void Get3DPoints(std::vector<HomgPoint3D>& p)
const;
179 void Get3DMovingPoints(std::vector<HomgPoint3D>& p,
const int frame=0)
const;
182 void GetInliers(std::vector<bool>& inl)
const;
185 void GetGTNormalizedF(std::vector<std::vector<FMatrixBase> >& F)
const;
189 friend BIASUtils_EXPORT std::ostream&
192 friend BIASUtils_EXPORT std::istream&
196 { width = *_ImWidth; height = *_ImHeight; }
199 {
return *_SigmaImagePoints; }
210 int &max_mov_obj)
const
211 { max_inlier = *_NumStaticPoints;
212 max_outlier = *_NumStaticPoints + *_NumOutliers;
213 max_mov_obj = *_NumMovingPoints * *_NumMovingObjects +
214 *_NumStaticPoints + *_NumOutliers; }
216 int CreateGTVRML(
const std::string& file_name)
const;
226 std::vector<BIAS::RMatrixBase>
_GT_R;
229 std::vector<BIAS::HomgPoint3D>
_GT_C;
232 std::vector<BIAS::PMatrixBase>
_GT_P;
273 *_MovingObjMotionVecZ, *_MovingObjRotVecX, *_MovingObjRotVecY,
308 void _CreateCamMovement(
const bool fixed_error);
311 void _CreateMovingTransforms();
315 int _CreateStatic3DPoints();
319 int _AreMovingObjectsVisible();
324 int _CreateMoving3DPoints();
330 int _CreateStatic2DPoints(
int &index);
335 int _CreateStaticGT2DPoints(
int &index);
339 void _AddUniformDistributedOutliers();
344 int _CreateMoving2DPoints(
int &index);
348 int _CreateMovingGT2DPoints(
int &index);
351 virtual void _AddParameter(
Param ¶);
355 const std::vector<std::vector<HomgPoint2D> >* p)
const;
359 const std::vector<std::vector<HomgPoint2D> >* p)
const;
363 return (p[0]>=border && p[0]<=(((
double)*_ImWidth)-border-1.0) &&
364 p[1]>=border && p[1]<=(((
double)*_ImHeight)-border-1.0));
367 bool _CheckParams()
const;
369 int CreateVRML_(
const std::string& file_name,
370 const std::vector<PMatrix> &P,
371 const std::vector<HomgPoint3D>& p)
const;
375 BIASUtils_EXPORT std::ostream&
operator<<(std::ostream& os,
const GenSynthMatches& m);
381 #include <Base/Common/BIASpragmaEnd.hh>
std::vector< BIAS::HomgPoint3D > _MovingPoints
BIAS::Vector< double > * _MovingObjRotVecZ
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
int GetMoving3DPoints(std::vector< BIAS::HomgPoint3D > &points)
read the moving 3D points used for computaion
void CreateCamMovement(const bool fixed_error=false)
see _CreateCamMovement for docu
bool _IsSeen(HomgPoint2D &p, double border=0.0)
BIAS::Vector< double > * _SizeMovingObjZ
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
std::vector< BIAS::RMatrixBase > _GT_R
int SetStatic3DPoints(const std::vector< BIAS::HomgPoint3D > &points)
set the static 3D points used for computation
std::vector< std::vector< HomgPoint2D > > _GT_Points
int GetNumMovingObjects()
std::vector< BIAS::HomgPoint3D > _StaticPoints
class for generating synthetic matches
void GetPointSourceBorders(int &max_inlier, int &max_outlier, int &max_mov_obj) const
when getting point list for an image, inidices 0 - max_inlier-1 are true matches generated by static ...
double * _SigmaImagePoints
int SetMoving3DPoints(const std::vector< BIAS::HomgPoint3D > &points)
set the moving 3D points used for computation
double * _PrinciplePointY
void CreateMovingTransforms()
fills _MovingTransform
int GetStatic3DPoints(std::vector< BIAS::HomgPoint3D > &points)
read the static 3D points used for computation
class for representing matches, used in GenSynthMatches and biasshowsm
int GetMovingTransforms(std::vector< BIAS::EuclideanTransf3D > &res)
class BIASGeometry_EXPORT PMatrix
void GetImageSize(int &width, int &height) const
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
describes a projective 3D -> 2D mapping in homogenous coordinates
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
This class Param provides generic support for parameters.
std::vector< BIAS::EuclideanTransf3D > _MovingTransform
double * _SigmaCamCenterZ
double GetSigmaImagePoints() const
Implements a 3D rotation matrix.
BIAS::Vector< double > * _RotVecZ
std::vector< BIAS::PMatrixBase > _GT_P
std::vector< BIAS::HomgPoint3D > _GT_C
class for producing random numbers from different distributions
double * _OutlLengthChange
BIASCommon_EXPORT std::istream & operator>>(std::istream &is, BIAS::TimeStamp &ts)
Standard input operator for TimeStamps.
class BIASGeometryBase_EXPORT HomgPoint3D
std::vector< std::vector< HomgPoint2D > > _GT_NormalizedPoints