34 #include <Geometry/Triangulation.hh>
35 #include <Geometry/RMatrix.hh>
36 #include <Geometry/PMatrix.hh>
37 #include <Base/Geometry/KMatrix.hh>
38 #include "Geometry/CovMatrix3x3.hh"
48 PMatrix pleft,pleftScale,pleftScaleTriang,pright,prightScale,prightScaleTriang;
49 ifstream infileL(
"left.matrix");
50 ifstream infileR(
"right.matrix");
63 rleft.
SetXYZ(0.0, 0.0, 0.0);
64 rright.
SetXYZ(0.0, 0.0, 0.0); Rscale.
SetXYZ(0.4, 0.0, 0.0);
69 Cleft.
Set(0.0, 0.0, 0.0);
70 Cright.
Set(2.5, 0.0, -5.0);
72 pright.
Compose(K, rright, Cright);
76 CleftScaleShift=scale*Cleft;
77 CleftScaleShift +=shift;
78 CrightScaleShift=scale*Cright;
79 CrightScaleShift+=shift;
80 pleftScale.
Compose(K, Rscale, CleftScaleShift);
82 prightScale.
Compose(K, Rscale, CrightScaleShift);
88 if (infileL) infileL>>pleft;
89 if (infileR) infileR>>pright;
90 cout<<
"Read:"<<endl<<pleft<< endl <<pleftScale<<endl<<pright<<endl;
92 for (
int i = 0; i <=5; i++){
95 for (
int k=0; k<3; k++)
97 point3d[k]=10.0*rand()/(RAND_MAX+1.0)-5;
102 point2d_im1s(pleftScale*point3d);
104 point2d_im2s(prightScale*point3d);
105 point2d_im1.Homogenize();point2d_im1s.Homogenize();
106 point2d_im2.Homogenize();point2d_im2s.Homogenize();
113 if (triangulator.
Triangulate(pleft, pright, point2d_im1, point2d_im2,
115 cerr <<
"error triangulating using SVD"<<endl;
118 cout <<
"p3 =" << p3;
119 triangulator.
Triangulate(pleftScaleTriang, prightScaleTriang,
120 point2d_im1s, point2d_im2s, eucl3d);
123 vp3s = Rscale*vp3s*scale+shift;
124 cout <<
"p3 with scaled, rot baseline= " << p3s <<
", vp3s = "
126 cout <<
"error is [" << (vp3s[0]-p3[0])/p3[0] <<
", " << (vp3s[1]-p3[1])/p3[1]
127 <<
", " <<(vp3s[2]-p3[2])/p3[2] <<
"] " << endl;
158 cout<<
"Now triangulation of:"<<pl<<
" "<<pr<<endl;
160 cout<<
"result of Triangluation: "<<
161 triangulator.
Triangulate(pleft, pright, pl, pr, eucl3d)<<endl;
163 cout<<
"p3: "<<p3<<endl;
176 cout<<
"Interscection of: a and b:"<<
177 triangulator.
Intersect(a1,a2,b1,b2)<<endl;
179 cout<<
"Interscection of: b and a:"<<
180 triangulator.
Intersect(b1,b2,a1,a2)<<endl;
void Set(const T *pv)
copy the array of vectorsize beginning at *T to this->data_
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
void SetXYZ(ROTATION_MATRIX_TYPE PhiX, ROTATION_MATRIX_TYPE PhiY, ROTATION_MATRIX_TYPE PhiZ)
Set Euler angles (in rad) in order XYZ.
void Set(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z)
set elementwise with given 3 euclidean scalar values.
Class for triangulation of 3Dpoints from 2D matches. Covariance matrix (refering to an uncertainty el...
int Triangulate(PMatrix &P1, PMatrix &P2, const HomgPoint2D &p1, const HomgPoint2D &p2, BIAS::Vector3< double > &point3d)
Triangulation for metric PMatrices (using C and Hinf)
void InvalidateDecomposition()
to re-Decompose_() after filling with data use this.
class for 3x3 covariance matrices
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
describes a projective 3D -> 2D mapping in homogenous coordinates
void Set(const HOMGPOINT2D_TYPE &x, const HOMGPOINT2D_TYPE &y)
set elementwise with given 2 euclidean scalar values.
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' | -K R' C ] with R' = transpose(R) ...
int Intersect(Vector3< double > &pA, Vector3< double > &dirA, Vector3< double > &pB, Vector3< double > &dirB, Vector3< double > &res)
analytic correct intersection of two lines, point returned has minimum distance to both lines...
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...