Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GenGroundTruth.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #include "GenGroundTruth.hh"
27 
28 #include <Base/Debug/Debug.hh>
29 #include <Base/Math/Random.hh>
30 #include <Geometry/RMatrix.hh>
31 #include <Base/Geometry/KMatrix.hh>
32 #include <Base/Math/Vector3.hh>
33 #include <Base/Geometry/HomgLine2D.hh>
34 #include <Base/Geometry/HomgPoint3D.hh>
35 #include <Base/ImageUtils/ImageDraw.hh>
36 
37 using namespace BIAS;
38 using namespace std;
39 
40 void GenGroundTruth::NormalizeMatches(vector<BIAS::HomgPoint2D>& match1,
41  vector<BIAS::HomgPoint2D>& match2,
42  KMatrix K)
43 {
44  KMatrix Kinv=K.Invert();
45  for (unsigned int i=0; i<match1.size(); i++){
46  match1[i]=Kinv*match1[i];
47  match2[i]=Kinv*match2[i];
48  }
49 }
50 
51 void GenGroundTruth::DeNormalizeMatches(vector<BIAS::HomgPoint2D>& match1,
52  vector<BIAS::HomgPoint2D>& match2,
53  KMatrix K)
54 {
55  for (unsigned int i=0; i<match1.size(); i++){
56  match1[i]=K*match1[i];
57  match2[i]=K*match2[i];
58  }
59 }
60 
62  vector<BIAS::HomgPoint2D>& match1,
63  vector<BIAS::HomgPoint2D>& match2,
64  unsigned char lcolor, unsigned char mcolor)
65 {
66  unsigned int start[2], end[2];
67  HomgLine2D line;
68  unsigned int coo[4];
69 
70  for (unsigned int i=0; i<match1.size(); i++){
71  start[0]=(unsigned int)rint(match1[i][0]);
72  start[1]=(unsigned int)rint(match1[i][1]);
73  end[0]=(unsigned int)rint(match2[i][0]);
74  end[1]=(unsigned int)rint(match2[i][1]);
75  line.Set(match1[i], match2[i]);
76  line.GetIntersectionsWithImage(im.GetWidth(), im.GetHeight(), coo);
77  if (ImageDraw<unsigned char>::Line(im, &(coo[0]), &(coo[2]), lcolor)!=0){
78  BIASERR("error drawing epipolar line "<<i);
79  }
80  }
81  for (unsigned int i=0; i<match1.size(); i++){
82  start[0]=(unsigned int)rint(match1[i][0]);
83  start[1]=(unsigned int)rint(match1[i][1]);
84  end[0]=(unsigned int)rint(match2[i][0]);
85  end[1]=(unsigned int)rint(match2[i][1]);
86  if (ImageDraw<unsigned char>::Line(im, start, end, mcolor)!=0){
87  BIASERR("error drawing match "<<i<<" ("<<start[0]<<", "<<start[1]
88  <<") ("<<end[0]<<", "<<end[1]<<") "<<match1[i]<<" <--> "
89  <<match2[i]);
90  }
91  }
92 }
93 
94 
95 void GenGroundTruth::CreateIdealMatches(vector<PMatrix>& pvec, unsigned num,
96  unsigned width, unsigned height,
97  vector<vector<HomgPoint2D> >& matches,
98  vector<HomgPoint3D>& points,
99  double minx, double maxx, double miny, double maxy,
100  double minz, double maxz)
101 {
102  Random ran;
103  unsigned i;
104  HomgPoint3D p3d(0.0, 0.0, 0.0);
105  HomgPoint2D p2d(0.0, 0.0);
106  vector<HomgPoint2D> p2vec;
107  unsigned numim=pvec.size();
108  bool done;
109 
110  p2vec.resize(numim);
111  points.clear();
112  for (i=0; i<matches.size(); i++)
113  matches[i].clear();
114  matches.clear();
115 
116  for (i=0; i<num; i++){
117  do {
118  p3d[0]=ran.GetUniformDistributed(minx, maxx);
119  p3d[1]=ran.GetUniformDistributed(miny, maxy);
120  p3d[2]=ran.GetUniformDistributed(minz, maxz);
121  done=true;
122  p2vec.clear();
123  for (unsigned j=0; j<numim; j++){
124  p2d=pvec[i]*p3d;
125  p2d.Homogenize();
126  if (p2d[0]>=0 && p2d[0]<width-1 && p2d[1]>=0 && p2d[1]<height-1){
127  p2vec.push_back(p2d);
128  } else {
129  done=false;
130  break;
131  }
132  }
133  } while (!done);
134  points.push_back(p3d);
135  matches.push_back(p2vec);
136  }
137 }
138 
139 
140 void GenGroundTruth::CreateMatches(vector<PMatrix>& pvec, unsigned num,
141  unsigned width, unsigned height, double spatial_noise,
142  vector<vector<HomgPoint2D> >& i_matches,
143  vector<vector<HomgPoint2D> >& n_matches,
144  vector<HomgPoint3D>& points,
145  double minx, double maxx, double miny, double maxy,
146  double minz, double maxz)
147 {
148  Random ran;
149  unsigned i;
150  HomgPoint3D p3d(0.0, 0.0, 0.0);
151  HomgPoint2D p2d(0.0, 0.0), n_p2d(0.0, 0.0);
152  vector<HomgPoint2D> p2vec;
153  vector<HomgPoint2D> noisy_p2vec;
154  unsigned numim=pvec.size();
155  bool done;
156  p2vec.resize(numim);
157  points.clear();
158  for (i=0; i<i_matches.size(); i++)
159  i_matches[i].clear();
160  for (i=0; i<n_matches.size(); i++)
161  n_matches[i].clear();
162  i_matches.clear();
163  n_matches.clear();
164 
165  for (i=0; i<num; i++){
166  do {
167  p3d[0]=ran.GetUniformDistributed(minx, maxx);
168  p3d[1]=ran.GetUniformDistributed(miny, maxy);
169  p3d[2]=ran.GetUniformDistributed(minz, maxz);
170  done=true;
171  p2vec.clear();
172  noisy_p2vec.clear();
173  for (unsigned j=0; j<numim; j++){
174  p2d=pvec[i]*p3d;
175  p2d.Homogenize();
176  n_p2d[0]=p2d[0]+ran.GetNormalDistributed(0.0, spatial_noise);
177  n_p2d[1]=p2d[1]+ran.GetNormalDistributed(0.0, spatial_noise);
178  if (p2d[0]>=0 && p2d[0]<width-1 && p2d[1]>=0 && p2d[1]<height-1 &&
179  n_p2d[0]>=0 && n_p2d[0]<width-1
180  && n_p2d[1]>=0 && n_p2d[1]<height-1){
181  p2vec.push_back(p2d);
182  noisy_p2vec.push_back(n_p2d);
183  } else {
184  done=false;
185  break;
186  }
187  }
188  } while (!done);
189  points.push_back(p3d);
190  i_matches.push_back(p2vec);
191  n_matches.push_back(noisy_p2vec);
192  }
193 }
194 
195 void GenGroundTruth::CreateMatches(vector<PMatrix>& pvec, vector<PMatrix>& n_pvec,
196  unsigned num, unsigned width, unsigned height,
197  double spatial_noise, double r_noise, double c_noise,
198  vector<vector<HomgPoint2D> >& i_matches,
199  vector<vector<HomgPoint2D> >& n_matches,
200  vector<HomgPoint3D>& points,
201  double minx, double maxx, double miny, double maxy,
202  double minz, double maxz, bool print)
203 {
204  Random ran;
205  unsigned i;
206  HomgPoint3D p3d(0.0, 0.0, 0.0);
207  HomgPoint2D p2d(0.0, 0.0), n_p2d(0.0, 0.0);
208  vector<HomgPoint2D> p2vec;
209  vector<HomgPoint2D> noisy_p2vec;
210  unsigned numim=pvec.size();
211  bool done;
212  RMatrix R;
213  KMatrix K;
214  Vector3<double> C, r;
215  PMatrix P;
216 
217  p2vec.resize(numim);
218  points.clear();
219  for (i=0; i<i_matches.size(); i++)
220  i_matches[i].clear();
221  for (i=0; i<n_matches.size(); i++)
222  n_matches[i].clear();
223  i_matches.clear();
224  n_matches.clear();
225 
226 
227  // create noisy P matrices
228  n_pvec.clear();
229  for (i=0; i<numim; i++){
230  if (pvec[i].GetK(K) || pvec[i].GetR(R) || pvec[i].GetC(C)){
231  BIASERR("error decomposing pvec["<<i<<"] : "<<pvec[i]<<"\nK: "<<K
232  <<"\nR: "<<R<<"\nC: "<<C);
233  return;
234  }
235  if (R.GetRotationAnglesXYZ(r[0], r[1], r[2])){
236  BIASERR("error extracting rotation angles from R: "<<R);
237  return;
238  }
239  cerr << setw(4) <<i<<" : true C : "<<C
240  <<"\n true R : "<<r<<endl;
241  if (i>0){ // first camera is usually known exact
242  r[0]+=ran.GetNormalDistributed(0.0, r_noise);
243  r[1]+=ran.GetNormalDistributed(0.0, r_noise);
244  r[2]+=ran.GetNormalDistributed(0.0, r_noise);
245  R.SetXYZ(r[0], r[1], r[2]);
246  C[0]+=ran.GetNormalDistributed(0.0, c_noise);
247  C[1]+=ran.GetNormalDistributed(0.0, c_noise);
248  C[2]+=ran.GetNormalDistributed(0.0, c_noise);
249  }
250  cerr << " noisy C : "<<C
251  <<"\n noisy R : "<<r<<endl;
252 
253  P.Compose(K, R, C);
254  n_pvec.push_back(P);
255  }
256 
257  // create points
258  cerr <<"creating 3D points and matches"<<endl;
259  for (i=0; i<num; i++){
260  do {
261  p3d[0]=ran.GetUniformDistributed(minx, maxx);
262  p3d[1]=ran.GetUniformDistributed(miny, maxy);
263  p3d[2]=ran.GetUniformDistributed(minz, maxz);
264  done=true;
265  p2vec.clear();
266  noisy_p2vec.clear();
267  for (unsigned j=0; j<numim; j++){
268  p2d=pvec[j]*p3d;
269  p2d.Homogenize();
270  n_p2d=n_pvec[j]*p3d;
271  n_p2d.Homogenize();
272  n_p2d[0]+=ran.GetNormalDistributed(0.0, spatial_noise);
273  n_p2d[1]+=ran.GetNormalDistributed(0.0, spatial_noise);
274  if (p2d[0]>=0 && p2d[0]<width-1 && p2d[1]>=0 && p2d[1]<height-1 &&
275  n_p2d[0]>=0 && n_p2d[0]<width-1 &&
276  n_p2d[1]>=0 && n_p2d[1]<height-1){
277  p2vec.push_back(p2d);
278  noisy_p2vec.push_back(n_p2d);
279  } else {
280  done=false;
281  break;
282  }
283  }
284  if (done) cout << "*"; else cout <<".";
285  cout.flush();
286  } while (!done);
287  points.push_back(p3d);
288  i_matches.push_back(p2vec);
289  n_matches.push_back(noisy_p2vec);
290  }
291  cout << endl;
292 
293  if (print){
294  cout <<"3D points and matches:"<<endl;
295  for (unsigned i=0; i<num; i++){
296  cout <<setw(3) << i <<": true "<<points[i]<<" \t: ";
297  for (unsigned k=0; k<numim; k++)
298  cout <<k<<i_matches[i][k]<<" ";
299  cout <<endl;
300  cout <<" noisy "<<points[i]<<" \t: ";
301  for (unsigned k=0; k<numim; k++)
302  cout <<k<<n_matches[i][k]<<" ";
303  cout <<endl;
304  }
305  cout << endl;
306  }
307 
308 }
309 
310 
311 void GenGroundTruth::CreateMatchesOutlier(vector<BIAS::PMatrix>& pvec,
312  vector<BIAS::PMatrix>& n_pvec, unsigned num,
313  unsigned width, unsigned height,
314  double spatial_noise, double r_noise,
315  double c_noise, double outlier_fraction,
316  vector<vector<BIAS::HomgPoint2D> >& i_matches,
317  vector<vector<BIAS::HomgPoint2D> >& n_matches,
318  vector<BIAS::HomgPoint3D>& points,
319  double minx/*=-50.0*/, double maxx/*=50.0*/,
320  double miny/*=-50.0*/, double maxy/*=50.0*/,
321  double minz/*=-50.0*/, double maxz/*=50.0*/,
322  bool print)
323 {
324  Random ran;
325  unsigned inlier, outlier;
326  outlier=(unsigned)rint((double)num*outlier_fraction);
327  inlier=num-outlier;
328  unsigned numim=pvec.size();
329  double offsetx, offsety;
330 
331  CreateMatches(pvec, n_pvec, num, width, height, spatial_noise, r_noise,
332  c_noise, i_matches, n_matches, points, minx, maxx, miny, maxy,
333  minz, maxz, false);
334 
335  for (unsigned i=inlier; i<num; i++){
336  cerr << i << "is outlier" << endl;
337  offsetx=ran.GetUniformDistributed(3+2*spatial_noise, 10);
338  offsety=ran.GetUniformDistributed(3+2*spatial_noise, 10);
339  for (unsigned j=1; j<numim;j++){
340  n_matches[i][j][0]+=j*offsetx;
341  n_matches[i][j][1]+=j*offsety;
342  i_matches[i][j][0]+=j*offsetx;
343  i_matches[i][j][1]+=j*offsety;
344  }
345  }
346 
347  if (print){
348  inlier=num-outlier;
349 
350  cout <<"3D points and matches:"<<endl;
351  for (unsigned i=0; i<num; i++){
352 
353  if (i<inlier) cout << "inl "; else cout << "outl ";
354  cout << setw(3) << i <<": true ";//<<points[i]<<" \t: ";
355  for (unsigned k=0; k<numim; k++){
356  cout <<k<<i_matches[i][k]<<"-"
357  <<pvec[k].GetK().Invert()*i_matches[i][k]<<"\t";
358  }
359  cout <<endl;
360 
361  cout <<" noisy ";//<<points[i]<<" \t: ";
362  for (unsigned k=0; k<numim; k++)
363  cout <<k<<n_matches[i][k]<<"-"
364  <<n_pvec[k].GetK().Invert()*n_matches[i][k]<<"\t";
365  cout <<endl;
366 
367  }
368  cout << endl;
369  }
370 
371 }
372 
373 void GenGroundTruth::GenerateRandomPlane(vector<BIAS::HomgPoint3D> &Points,
374  int n,
375  double aX, double aY, double aZ,
376  double alphaX, double alphaY, double alphaZ,
377  double betaX, double betaY, double betaZ,
378  double alphamax,
379  double betamax)
380 {
381  GenerateRandomCube(Points, n, aX, aY, aZ,
382  alphaX, alphaY, alphaZ,
383  betaX, betaY, betaZ,
384  0.0, 0.0, 0.0,
385  alphamax, betamax, 0);
386 }
387 
388 void GenGroundTruth::GenerateRandomCube(vector<BIAS::HomgPoint3D> &Points,
389  int n,
390  double aX, double aY, double aZ,
391  double alphaX, double alphaY, double alphaZ,
392  double betaX, double betaY, double betaZ,
393  double gammaX, double gammaY, double gammaZ,
394  double alphamax,
395  double betamax,
396  double gammamax)
397 {
398  Random ran;
399  double f1,f2,f3;
400  Vector3<double> newpoint;
401  HomgPoint3D newHomgPoint;
402  Vector3<double> a(aX,aY,aZ);
403  Vector3<double> alpha(alphaX,alphaY,alphaZ);
404  Vector3<double> beta(betaX,betaY,betaZ);
405  Vector3<double> gamma(gammaX,gammaY,gammaZ);
406  alpha.Normalize();
407  beta.Normalize();
408  gamma.Normalize();
409  for(int i=0;i<n;i++)
410  {
411  f1=ran.GetUniformDistributed(0.0,alphamax);
412  f2=ran.GetUniformDistributed(0.0,betamax);
413  f3=ran.GetUniformDistributed(0.0,gammamax);
414  newpoint = a + f1*alpha + f2*beta + f3*gamma;
415  newHomgPoint=newpoint;
416  Points.push_back(newHomgPoint);
417  }
418 }
419 
420 int GenGroundTruth::ReadCorrespondences(const char *Filename,
421  vector<HomgPoint2D> &Points1,
422  vector<HomgPoint2D> &Points2)
423 {
424  ifstream filein;
425  double x,y,w;
426  Points1.clear();
427  Points2.clear();
428  filein.open(Filename, ios::in);
429  if ( !filein.is_open() )
430  {
431  cerr << "Error opening file '" << Filename << "'" << endl;
432  return -1;
433  }
434  while ( !filein.eof() )
435  {
436  filein.read( (char*) &x,sizeof(HOMGPOINT2D_TYPE) );
437  filein.read( (char*) &y,sizeof(HOMGPOINT2D_TYPE) );
438  filein.read( (char*) &w,sizeof(HOMGPOINT2D_TYPE) );
439  Points1.push_back(HomgPoint2D(x,y,w));
440  filein.read( (char*) &x,sizeof(HOMGPOINT2D_TYPE) );
441  filein.read( (char*) &y,sizeof(HOMGPOINT2D_TYPE) );
442  filein.read( (char*) &w,sizeof(HOMGPOINT2D_TYPE) );
443  Points2.push_back(HomgPoint2D(x,y,w));
444  }
445  // the last correspondence is always read in twice so we cut one off
446  Points1.pop_back();
447  Points2.pop_back();
448  filein.close();
449  assert( Points1.size() == Points2.size() );
450  return Points1.size();
451 }
452 
453 
454 int GenGroundTruth::WriteCorrespondences(const char *Filename,
455  vector<HomgPoint2D> &Points1,
456  vector<HomgPoint2D> &Points2)
457 {
458  assert( Points1.size() == Points2.size() );
459  ofstream fileout;
460  fileout.open(Filename, ios::out);
461  if ( !fileout.is_open() )
462  {
463  cerr << "Error opening file '" << Filename << "'" << endl;
464  return -1;
465  }
466  for(unsigned int i=0;i<Points1.size();i++)
467  {
468  fileout.write( (char*) &Points1[i][0],sizeof(HOMGPOINT2D_TYPE) );
469  fileout.write( (char*) &Points1[i][1],sizeof(HOMGPOINT2D_TYPE) );
470  fileout.write( (char*) &Points1[i][2],sizeof(HOMGPOINT2D_TYPE) );
471  fileout.write( (char*) &Points2[i][0],sizeof(HOMGPOINT2D_TYPE) );
472  fileout.write( (char*) &Points2[i][1],sizeof(HOMGPOINT2D_TYPE) );
473  fileout.write( (char*) &Points2[i][2],sizeof(HOMGPOINT2D_TYPE) );
474  }
475  fileout.close();
476  return Points1.size();
477 }
478 
479 
480 int GenGroundTruth::ReadWorldPoints( const char *Filename,
481  vector<HomgPoint3D> & Points )
482 {
483  ifstream filein;
484  double x,y,z,w;
485  Points.clear();
486  filein.open(Filename, ios::in);
487  if ( !filein.is_open() )
488  {
489  cerr << "Error opening file '" << Filename << "'" << endl;
490  return -1;
491  }
492  while ( !filein.eof() )
493  {
494  filein.read( (char*) &x,sizeof(HOMGPOINT3D_TYPE) );
495  filein.read( (char*) &y,sizeof(HOMGPOINT3D_TYPE) );
496  filein.read( (char*) &z,sizeof(HOMGPOINT3D_TYPE) );
497  filein.read( (char*) &w,sizeof(HOMGPOINT3D_TYPE) );
498  Points.push_back(HomgPoint3D(x,y,z,w));
499  }
500  // the last coordinate is always read in twice so we cut one off
501  Points.pop_back();
502  filein.close();
503  return Points.size();
504 }
505 
506 
507 int GenGroundTruth::WriteWorldPoints( const char *Filename,
508  vector<HomgPoint3D> & Points )
509 {
510  ofstream fileout;
511  fileout.open(Filename, ios::out);
512  if ( !fileout.is_open() )
513  {
514  cerr << "Error opening file '" << Filename << "'" << endl;
515  return -1;
516  }
517  for(unsigned int i=0;i<Points.size();i++)
518  {
519  fileout.write( (char*) &Points[i][0],sizeof(HOMGPOINT3D_TYPE) );
520  fileout.write( (char*) &Points[i][1],sizeof(HOMGPOINT3D_TYPE) );
521  fileout.write( (char*) &Points[i][2],sizeof(HOMGPOINT3D_TYPE) );
522  fileout.write( (char*) &Points[i][3],sizeof(HOMGPOINT3D_TYPE) );
523  }
524  fileout.close();
525  return Points.size();
526 }
527 
528 
static void CreateMatchesOutlier(std::vector< BIAS::PMatrix > &pvec, std::vector< BIAS::PMatrix > &n_pvec, unsigned num, unsigned width, unsigned height, double spatial_noise, double r_noise, double c_noise, double outlier_fraction, std::vector< std::vector< BIAS::HomgPoint2D > > &i_matches, std::vector< std::vector< BIAS::HomgPoint2D > > &n_matches, std::vector< BIAS::HomgPoint3D > &points, double minx=-50.0, double maxx=50.0, double miny=-50.0, double maxy=50.0, double minz=-50.0, double maxz=50.0, bool print=false)
Generates ideal matches in cameras from pvec by randomly creating a 3D point in the cube between min[...
static void DeNormalizeMatches(std::vector< BIAS::HomgPoint2D > &match1, std::vector< BIAS::HomgPoint2D > &match2, BIAS::KMatrix K)
de-normalizes the matches by multiplying with K
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
void SetXYZ(ROTATION_MATRIX_TYPE PhiX, ROTATION_MATRIX_TYPE PhiY, ROTATION_MATRIX_TYPE PhiZ)
Set Euler angles (in rad) in order XYZ.
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint2D.hh:215
static int ReadWorldPoints(const char *Filename, std::vector< BIAS::HomgPoint3D > &Points)
Read 3D world coordinates from a file in binary format.
void Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint3D.hh:308
bool GetIntersectionsWithImage(unsigned int width, unsigned int height, unsigned int coo[4])
! assumes line is given in pixel coo ! returns true if line intersects with image of given size retur...
Definition: HomgLine2D.cpp:28
static int ReadCorrespondences(const char *Filename, std::vector< BIAS::HomgPoint2D > &Points1, std::vector< BIAS::HomgPoint2D > &Points2)
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
Definition: Random.hh:84
unsigned int GetWidth() const
Definition: ImageBase.hh:312
static void DrawMatches(BIAS::Image< unsigned char > &im, std::vector< BIAS::HomgPoint2D > &match1, std::vector< BIAS::HomgPoint2D > &match2, unsigned char lcolor, unsigned char mcolor)
draws the matches in image im with background 0, match in color mcolor and line defined by match in c...
3D rotation matrix
Definition: RMatrix.hh:49
void Set(const HomgPoint2D &p1, const HomgPoint2D &p2)
constructing a line through two points
Definition: HomgLine2D.hh:131
static int WriteWorldPoints(const char *Filename, std::vector< BIAS::HomgPoint3D > &Points)
Store 3D world coordinates in a file in binary format, so that you can keep the full accuracy of a do...
static void CreateIdealMatches(std::vector< BIAS::PMatrix > &pvec, unsigned num, unsigned width, unsigned height, std::vector< std::vector< BIAS::HomgPoint2D > > &matches, std::vector< BIAS::HomgPoint3D > &points, double minx=-50.0, double maxx=50.0, double miny=-50.0, double maxy=50.0, double minz=-50.0, double maxz=50.0)
Generates ideal matches in cameras from pvec by randomly creating a 3D point in the cube between min[...
static void NormalizeMatches(std::vector< BIAS::HomgPoint2D > &match1, std::vector< BIAS::HomgPoint2D > &match2, BIAS::KMatrix K)
normalizes the matches by multiplying with K^-1
unsigned int GetHeight() const
Definition: ImageBase.hh:319
static void GenerateRandomCube(std::vector< BIAS::HomgPoint3D > &Points, int n=200, double aX=-50.0, double aY=-50.0, double aZ=-50.0, double alphaX=1.0, double alphaY=0.0, double alphaZ=0.0, double betaX=0.0, double betaY=1.0, double betaZ=0.0, double gammaX=0.0, double gammaY=0.0, double gammaZ=1.0, double alphamax=100.0, double betamax=100.0, double gammamax=100.0)
Generates &#39;n&#39; points which are all located in a cube specified by space point coords aX...
a line l = (a b c)^T is a form of the implicit straight line equation 0 = a*x + b*y + c if homogenize...
Definition: HomgLine2D.hh:48
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
static void GenerateRandomPlane(std::vector< BIAS::HomgPoint3D > &Points, int n=200, double aX=-50.0, double aY=-50.0, double aZ=0.0, double alphaX=1.0, double alphaY=0.0, double alphaZ=0.0, double betaX=0.0, double betaY=1.0, double betaZ=0.0, double alphamax=100.0, double betamax=100.0)
Generates &#39;n&#39; points which are all located on a plane specified by space point coords aX...
int GetRotationAnglesXYZ(double &PhiX, double &PhiY, double &PhiZ) const
Get Euler angles for this rotation matrix in order XYZ.
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
double GetNormalDistributed(const double mean, const double sigma)
on succesive calls return normal distributed random variable with mean and standard deviation sigma ...
Definition: Random.hh:71
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
drawing simple entities into the image like rectangles or lines As all functions are static they have...
Definition: ImageDraw.hh:72
static int WriteCorrespondences(const char *Filename, std::vector< BIAS::HomgPoint2D > &Points1, std::vector< BIAS::HomgPoint2D > &Points2)
Store 2D picture correspondences in a file in binary format, so that you can keep the full accuracy o...
KMatrix Invert() const
returns analyticaly inverted matrix
Definition: KMatrix.cpp:31
static void CreateMatches(std::vector< BIAS::PMatrix > &pvec, unsigned num, unsigned width, unsigned height, double spatial_noise, std::vector< std::vector< BIAS::HomgPoint2D > > &i_matches, std::vector< std::vector< BIAS::HomgPoint2D > > &n_matches, std::vector< BIAS::HomgPoint3D > &points, double minx=-50.0, double maxx=50.0, double miny=-50.0, double maxy=50.0, double minz=-50.0, double maxz=50.0)
Generates ideal matches in cameras from pvec by randomly creating a 3D point in the cube between min[...
Vector3< T > & Normalize()
normalize this vector to length 1
Definition: Vector3.hh:663
class for producing random numbers from different distributions
Definition: Random.hh:51
class BIASGeometryBase_EXPORT HomgPoint2D
void Compose(const Matrix3x3< double > &K, const Matrix3x3< double > &R, const Vector3< double > &C)
composes this from K, R and C using P = [ K R&#39; | -K R&#39; C ] with R&#39; = transpose(R) ...
Definition: PMatrix.cpp:581
class BIASGeometryBase_EXPORT HomgPoint3D