25 #include <Base/Common/BIASpragma.hh>
27 #include "MatchDataBase.hh"
94 std::vector<HomgPoint3D>& C,
95 std::vector<std::vector<HomgPoint2D> >& m)
97 BIASASSERT(m.size()==R.size());
98 BIASASSERT(m.size()>0);
117 std::vector<HomgPoint3D>& C,
118 std::vector<std::vector<HomgPoint2D> >& m)
120 BIASASSERT(m.size()==R.size());
121 BIASASSERT(m.size()>0);
140 std::vector<HomgPoint3D>& C)
146 BIASASSERT(
_R.size() ==
_C.size());
147 _P.resize(
_R.size());
148 for (
unsigned i=0; i<
_R.size(); i++){
155 ofstream os(fname.c_str());
157 BIASERR(
"error opening "<<fname);
169 BIASCDOUT(D_MD_IO,
"using MatchDataBase::Write(ostream)\n");
170 BIASCDOUT(D_MD_IO,
"MatchDataBase::Write() writing "<<*
_NumImages<<
" images with "<<*
_NumPoints<<
" points in each\n");
175 os.write((
char*)
_K.
GetData(),
sizeof(KMATRIX_TYPE)*9);
178 os.write((
char*)
_R[i].GetData(),
sizeof(ROTATION_MATRIX_TYPE)*9);
179 os.write((
char*)
_C[i].GetData(),
sizeof(HOMGPOINT3D_TYPE)*4);
181 os.write((
char*)
_Points[i][k].GetData(),
sizeof(HOMGPOINT2D_TYPE)*3);
186 BIASERR(
"error writing data");
195 ifstream is(fname.c_str());
197 BIASERR(
"error opening "<<fname);
208 BIASCDOUT(D_MD_IO,
"using MatchDataBase::Read(ostream)\n");
212 is.read((
char*)
_K.
GetData(),
sizeof(KMATRIX_TYPE)*9);
221 is.read((
char*)
_R[i].GetData(),
sizeof(ROTATION_MATRIX_TYPE)*9);
222 is.read((
char*)
_C[i].GetData(),
sizeof(HOMGPOINT3D_TYPE)*4);
227 is.read((
char*)
_Points[i][k].GetData(),
sizeof(HOMGPOINT2D_TYPE)*3);
233 BIASERR(
"error reading data");
236 BIASCDOUT(D_MD_IO,
"MatchDataBase::Read() read "<<*_NumImages
237 <<
" images with "<<*
_NumPoints<<
" points in each\n");
248 res = res && (
_R[i] == r.
_R[i]) && (
_C[i] == r.
_C[i]) &&
250 if (!res) cerr <<
" R/C/P\n";
255 cerr <<
"_Points/_NormalizedPoints ["<<k<<
"]\n";
256 cerr << _Points[i][k]<<
" - "<<r.
_Points[i][k]<<
" = "
257 <<_Points[i][k]-r.
_Points[i][k]<<endl;
267 cerr <<
" Num/K/Ki\n";
290 numeric_limits<int>::max(), 0, grp);
297 30, 0, numeric_limits<int>::max(), 0, grp);
308 os <<
"K: "<<m.
_K<<endl;
311 os << setw(3) << i <<
" : " << m.
_P[i]<<endl;
315 os << setw(3) << k <<
" : ";
317 os <<i<<
":"<<m.
_Points[i][k] <<
" ";
321 os <<
"_NormalizedPoints: \n";
323 os << setw(3) << k <<
" : ";
334 BIASERR(
"unfinished");
void _SetCamData(KMatrix &K, std::vector< RMatrixBase > &R, std::vector< HomgPoint3D > &C)
std::vector< std::vector< HomgPoint2D > > _NormalizedPoints
int Read(const std::string &fname)
binary read
void GetR(int imNo, RMatrixBase &R) const
std::vector< PMatrixBase > _P
void GetK(KMatrix &K) const
MatchDataBase(Param ¶)
void SetNormalizedData(KMatrix &K, std::vector< RMatrixBase > &R, std::vector< HomgPoint3D > &C, std::vector< std::vector< HomgPoint2D > > &m)
void GetNormalizedCorrespondences(std::vector< std::vector< HomgPoint2D > > &p) const
same as GetNormalizedPoints with inverted indices : p[i][k] is point number i in image k ...
void GetPoints(int imNo, std::vector< HomgPoint2D > &p) const
void _Transpose(const std::vector< std::vector< HomgPoint2D > > &src, std::vector< std::vector< HomgPoint2D > > &dst) const
std::vector< RMatrixBase > _R
int Write(const std::string &fname) const
binary write
void GetCorrespondences(std::vector< std::vector< HomgPoint2D > > &p) const
same as GetPOints with inverted indices : p[i][k] is point number i in image k
void GetNormalizedPoints(int imNo, std::vector< HomgPoint2D > &p) const
bool CheckParam(const std::string &name)
Check if parameter has already been added.
class for representing matches, used in GenSynthMatches and biasshowsm
int * GetParamInt(const std::string &name) const
void GetC(int imNo, HomgPoint3D &C) const
int GetFreeGroupID()
returns unused group id
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)
virtual void _AddParameter(Param ¶)
This class Param provides generic support for parameters.
std::vector< HomgPoint3D > _C
std::vector< std::vector< HomgPoint2D > > _Points
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
Implements a 3D rotation matrix.
KMatrix Invert() const
returns analyticaly inverted matrix
void GetP(int imNo, PMatrixBase &P) const
int GetGroupID(const std::string &name)
returns group id of parameter with name
void SetData(KMatrix &K, std::vector< RMatrixBase > &R, std::vector< HomgPoint3D > &C, std::vector< std::vector< HomgPoint2D > > &m)
bool operator==(MatchDataBase &l)
BIASCommon_EXPORT std::istream & operator>>(std::istream &is, BIAS::TimeStamp &ts)
Standard input operator for TimeStamps.