33 #include "../FMatrix.hh"
34 #include "../FMatrixEstimation.hh"
35 #include "../PMatrixEstimation.hh"
36 #include "../PMatrixLinear.hh"
37 #include "../Triangulation.hh"
38 #include "../../Base/Math/Random.hh"
59 R2.
SetXYZ(0.0, 5.0*M_PI/180.0, 0.0);
65 C2[0] = -1.0/sqrt(2.0);
66 C2[1] = 1.0/sqrt(2.0);
91 vector<HomgPoint3D> points;
92 vector<HomgPoint2D> p1, p2;
95 vector<HomgPoint2D> p1Noisy, p2Noisy;
97 double testDist1, testDist2, testDist3, testDist4;
99 unsigned int numPoints = 80;
100 cout <<
"Randomized correspondences are "<<endl;
101 for (
unsigned int p=0; p<numPoints; p++) {
102 cout <<
"number " << p << endl;
105 p1.push_back(P1 * points[p]);
107 cout <<
"{ "<<p1[p]<<
" ";
108 p2.push_back(P2 * points[p]);
110 cout << p2[p]<<
" } "<<endl;
117 p1Noisy.push_back(
HomgPoint2D((p1[p])[0] + testDist1, (p1[p])[1] + testDist2));
118 p2Noisy.push_back(
HomgPoint2D((p2[p])[0] + testDist3, (p2[p])[1] + testDist4));
123 cout <<
"{ " << p1Noisy[p] <<
" " << p2Noisy[p] <<
" }" << endl;
126 bool NormalizeHartley =
true;
130 HomgPoint2D e8Point1, e8Point2, theoe1, theoe2, eGoldSt1, eGoldSt2, eOpt1, eOpt2;
131 double residualError8Point, residualErrorGoldStandard, residualErrorTest;
132 double residualError8Point_n, residualErrorGoldStandard_n, residualErrorTest_n;
133 double residualErrorOpt_n, residualErrorOpt;
142 FEstimator.Linear(FEightPoint, p1Noisy, p2Noisy);
150 FOptimize = FEightPoint;
151 FEstimator.Optimize(FOptimize, p1Noisy, p2Noisy);
160 FEstimator.GoldStandard(FGoldSt, p1Noisy, p2Noisy);
168 cout <<
"True F matrix " << 1/TheoF[2][2] * TheoF << endl;
169 cout <<
"Residual Error " << residualErrorTest <<
" noisy " << residualErrorTest_n << endl;
173 cout <<
"True epipoles are "<<theoe1<<
" and "<<theoe2<<endl;
176 cout <<
"Eight point algorithm " << endl;
177 cout <<
"Fmatrix " << 1/FEightPoint[2][2] * FEightPoint << endl;
178 cout <<
"Residual Error " << residualError8Point <<
" noisy " << residualError8Point_n << endl;
179 cout <<
"est. epipoles are "<<e8Point1<<
" and "<<e8Point2<<endl;
183 cout <<
"Optimize algorithm " << endl;
184 cout <<
"Fmatrix " << 1/FOptimize[2][2] * FOptimize << endl;
185 cout <<
"Residual Error " << residualErrorOpt <<
" noisy " << residualErrorOpt_n << endl;
186 cout <<
"est. epipoles are "<<eOpt1<<
" and "<<eOpt2<<endl;
191 cout <<
"Gold Standard algorithm" << endl;
192 cout <<
"Fmatrix " << 1/FGoldSt[2][2] * FGoldSt << endl;
193 cout <<
"Residual Error " << residualErrorGoldStandard <<
" noisy " << residualErrorGoldStandard_n << endl;
194 cout <<
"est. epipoles are "<<eGoldSt1<<
" and "<<eGoldSt2<<endl;
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 SetSkew(const KMATRIX_TYPE &val)
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
double GetResidualError(const std::vector< BIAS::HomgPoint2D > &p1, const std::vector< BIAS::HomgPoint2D > &p2)
returns residual error as in Zisserman p.
class representing a Fundamental matrix
void InvalidateDecomposition()
to re-Decompose_() after filling with data use this.
functions for estimating a fundamental matrix (FMatrix) given a set of 2d-2d correspondences (no outl...
void ComputeFromPMatrices(BIAS::PMatrix &P1, BIAS::PMatrix &P2)
computes an F matrix from two cameras (defined by arbitrary P matrices, not only metric ones) ...
void GetEpipolesHomogenized(HomgPoint2D &E1, HomgPoint2D &E2) const
same as above, additionally homogenizes epipoles
void SetFx(const KMATRIX_TYPE &val)
void SetHy(const KMATRIX_TYPE &val)
void SetFy(const KMATRIX_TYPE &val)
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
describes a projective 3D -> 2D mapping in homogenous coordinates
void SetHx(const KMATRIX_TYPE &val)
Vector3< T > & Normalize()
normalize this vector to length 1
class for producing random numbers from different distributions
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' | -K R' C ] with R' = transpose(R) ...
class BIASGeometryBase_EXPORT HomgPoint3D
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...