Basic Image AlgorithmS Library
2.8.0
|
Estimate 3x3 matrix relating image coordinates with each other, i.e. More...
#include <Geometry/HMatrixEstimation.hh>
Public Member Functions | |
int | Compute (const std::vector< BIAS::HomgPoint2D > &fromPoints, const std::vector< BIAS::HomgPoint2D > &toPoints, HMatrix &H) |
Calculate homography between 2d points using the DLT. More... | |
int | Compute (const std::vector< BIAS::Vector2< double > > &fromPoints, const std::vector< BIAS::Vector2< double > > &toPoints, HMatrix &H) |
Calculate homography between 2d points using the DLT. More... | |
int | ComputeAffine (const std::vector< BIAS::HomgPoint2D > &fromPoints, const std::vector< BIAS::HomgPoint2D > &toPoints, HMatrix &H) |
Compute affine transformation between 2d points, i.e. More... | |
double | GetError () const |
Returns the average squared error of the estimation applying the estimated homography matrix to all correspondences. More... | |
HMatrixEstimation (bool normalizeHartley=true) | |
Create homography estimation instance. More... | |
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. More... | |
void | SetNormalizeHartley (bool normalize) |
Decide whether to normalize input vector as proposed by Hartley (strongly recommended) or use the DLT on raw data. More... | |
~HMatrixEstimation () | |
Static Protected Member Functions | |
static int | HErrorFunction_ (void *p, int m, int n, const double *x, double *fvec, int iflag) |
Objective function for Levenberg-Marquardt optimization. More... | |
Protected Attributes | |
HMatrix | H_ |
Stores the estimated homography matrix (used in GetError) More... | |
Normalization | normalization_ |
The normalization algorithm instance. More... | |
bool | normalizeHartley_ |
Flag indicating whether we should normalize the given points before and denormalize the homography matrix after computation, so that it refers to the original points. More... | |
std::vector< BIAS::HomgPoint2D > | pointsFrom_ |
Stores the points in image 1 (used in Optimize and GetError) More... | |
std::vector< BIAS::HomgPoint2D > | pointsTo_ |
Stores the points in image 2 (used in Optimize and GetError) More... | |
Estimate 3x3 matrix relating image coordinates with each other, i.e.
a homography or affine transformation.
Definition at line 48 of file HMatrixEstimation.hh.
|
inlineexplicit |
Create homography estimation instance.
normalizeHartley | Use normalization of input vectors proposed by Hartley (strongly recommended) or use the DLT on raw data |
Definition at line 56 of file HMatrixEstimation.hh.
|
inline |
Definition at line 59 of file HMatrixEstimation.hh.
int HMatrixEstimation::Compute | ( | const std::vector< BIAS::HomgPoint2D > & | fromPoints, |
const std::vector< BIAS::HomgPoint2D > & | toPoints, | ||
HMatrix & | H | ||
) |
Calculate homography between 2d points using the DLT.
The direct linear transformation algorithm (see Hartley & Zisserman: "Multiple View Geometry", p.73) solves the equation system (p' x (H * p) = 0 in order to solve p' ~ H * p where p, p' are 2d image coordinates in homogeneous coordinates. Each correspondence provides 3 equation, but the linear equation system has but rank 2, so we take only the first two rows. The resulting equation system A*h = 0 s.t. |h| = 1 is solved via SVD where h is vector representation of matrix H.
fromPoints | Homogenized points in image 1 |
toPoints | Corresponding homogenized points in image 2 |
H | Returns estimated homography matrix |
Definition at line 92 of file HMatrixEstimation.cpp.
References General_singular_value_decomposition(), BIAS::Matrix3x3< T >::GetData(), BIAS::KMatrix::Invert(), and BIAS::Matrix3x3< T >::SetZero().
int HMatrixEstimation::Compute | ( | const std::vector< BIAS::Vector2< double > > & | fromPoints, |
const std::vector< BIAS::Vector2< double > > & | toPoints, | ||
HMatrix & | H | ||
) |
Calculate homography between 2d points using the DLT.
fromPoints | Homogenized points in image 1 |
toPoints | Corresponding homogenized points in image 2 |
H | Returns estimated homography matrix |
Definition at line 228 of file HMatrixEstimation.cpp.
int HMatrixEstimation::ComputeAffine | ( | const std::vector< BIAS::HomgPoint2D > & | fromPoints, |
const std::vector< BIAS::HomgPoint2D > & | toPoints, | ||
HMatrix & | H | ||
) |
Compute affine transformation between 2d points, i.e.
rotation and translation. This method is not using the DLT!
fromPoints | Homogenized points in image 1 |
toPoints | Corresponding homogenized points in image 2 |
H | Returns estimated affine transformation matrix |
Definition at line 162 of file HMatrixEstimation.cpp.
References General_singular_value_decomposition(), BIAS::Matrix3x3< T >::GetData(), BIAS::KMatrix::Invert(), BIAS::MatrixZero, and BIAS::Matrix3x3< T >::SetIdentity().
double HMatrixEstimation::GetError | ( | ) | const |
Returns the average squared error of the estimation applying the estimated homography matrix to all correspondences.
Definition at line 245 of file HMatrixEstimation.cpp.
References BIAS::HomgPoint2D::Homogenize(), and BIAS::Vector3< T >::size().
|
staticprotected |
Objective function for Levenberg-Marquardt optimization.
Definition at line 13 of file HMatrixEstimation.cpp.
References BIAS::Matrix3x3< T >::GetInverse(), BIAS::HomgPoint2D::Homogenize(), BIAS::Parametrization::ParamsToHMatrix(), pointsFrom_, and pointsTo_.
int HMatrixEstimation::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.
Minimize an error function on the homography matrix using iterative nonlinear optimization techniques such as Levenberg-Marquardt.
H | Homography matrix to optimize, provides starting point |
p1 | Homogenized points in image 1 |
p2 | Corresponding homogenized points in image 2 |
Definition at line 52 of file HMatrixEstimation.cpp.
References BIAS::Parametrization::HMatrixToParams(), BIAS::LevenbergMarquardt(), and BIAS::Parametrization::ParamsToHMatrix().
|
inline |
Decide whether to normalize input vector as proposed by Hartley (strongly recommended) or use the DLT on raw data.
Definition at line 116 of file HMatrixEstimation.hh.
|
protected |
Stores the estimated homography matrix (used in GetError)
Definition at line 139 of file HMatrixEstimation.hh.
|
protected |
The normalization algorithm instance.
Definition at line 136 of file HMatrixEstimation.hh.
|
protected |
Flag indicating whether we should normalize the given points before and denormalize the homography matrix after computation, so that it refers to the original points.
Definition at line 133 of file HMatrixEstimation.hh.
|
protected |
Stores the points in image 1 (used in Optimize and GetError)
Definition at line 142 of file HMatrixEstimation.hh.
Referenced by HErrorFunction_().
|
protected |
Stores the points in image 2 (used in Optimize and GetError)
Definition at line 145 of file HMatrixEstimation.hh.
Referenced by HErrorFunction_().