22 #include <Base/Math/Random.hh>
23 #include <Geometry/HMatrix.hh>
24 #include <Geometry/HMatrixEstimation.hh>
25 #include <Geometry/RMatrix.hh>
37 int main(
int argc,
char *argv[])
47 k1[0][2] = k1[1][2] = k1[0][0]/2.0;
50 k2[0][2] = k2[1][2] = k2[0][0]/2.0;
79 H1 = 1.0/H1[2][2] * H1;
81 H_gt = 1.0/H_gt[2][2] * H_gt;
91 for(
unsigned int i=0; i < 3; i++){
92 for(
unsigned int j=0; j < 3; j++){
98 unsigned int num_points = 5;
99 vector<HomgPoint2D> points2D_1;
100 vector<HomgPoint2D> points2D_2;
102 for(
unsigned int i=0; i < num_points; i++){
105 points2D_1.push_back(p2d);
106 p2d = H_gt2 * points2D_1[i];
108 points2D_2.push_back(p2d);
114 estimator.
Compute(points2D_1, points2D_2, Hest);
115 Hest = 1.0/Hest[2][2] * Hest;
117 if(residual > 1e-12){
122 estimator.
Optimize(Hopt, points2D_1, points2D_2);
123 Hopt = 1.0/Hopt[2][2] * Hopt;
125 if(residual > 1e-12){
129 cout <<
"done, passed" << 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.
a 3x3 Matrix describing projective transformations between planes
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
int Optimize(BIAS::HMatrix &H, const std::vector< BIAS::HomgPoint2D > &p1, const std::vector< BIAS::HomgPoint2D > &p2)
Optimize a given homography matrix from 2d point correspondences.
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
int Compute(const std::vector< BIAS::HomgPoint2D > &fromPoints, const std::vector< BIAS::HomgPoint2D > &toPoints, HMatrix &H)
Calculate homography between 2d points using the DLT.
double GetReprojectionError(std::vector< BIAS::HomgPoint2D > &p1, std::vector< BIAS::HomgPoint2D > &p2)
compute reprojection error for both vectors of HomgPoint2D
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
Estimate 3x3 matrix relating image coordinates with each other, i.e.
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
describes a projective 3D -> 2D mapping in homogenous coordinates
KMatrix Invert() const
returns analyticaly inverted matrix
class for producing random numbers from different distributions
class BIASGeometryBase_EXPORT HomgPoint2D
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...