Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
BIAS::HMatrixEstimation Class Reference

Estimate 3x3 matrix relating image coordinates with each other, i.e. More...

#include <Geometry/HMatrixEstimation.hh>

+ Collaboration diagram for BIAS::HMatrixEstimation:

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::HomgPoint2DpointsFrom_
 Stores the points in image 1 (used in Optimize and GetError) More...
 
std::vector< BIAS::HomgPoint2DpointsTo_
 Stores the points in image 2 (used in Optimize and GetError) More...
 

Detailed Description

Estimate 3x3 matrix relating image coordinates with each other, i.e.

a homography or affine transformation.

Author
koeser 12/2005
Examples:
ExampleHMatrixEstimation.cpp, and HMatrixTest.cpp.

Definition at line 48 of file HMatrixEstimation.hh.

Constructor & Destructor Documentation

BIAS::HMatrixEstimation::HMatrixEstimation ( bool  normalizeHartley = true)
inlineexplicit

Create homography estimation instance.

Parameters
normalizeHartleyUse normalization of input vectors proposed by Hartley (strongly recommended) or use the DLT on raw data

Definition at line 56 of file HMatrixEstimation.hh.

BIAS::HMatrixEstimation::~HMatrixEstimation ( )
inline

Definition at line 59 of file HMatrixEstimation.hh.

Member Function Documentation

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.

Parameters
fromPointsHomogenized points in image 1
toPointsCorresponding homogenized points in image 2
HReturns estimated homography matrix
Author
woelk/frahm
Examples:
ExampleHMatrixEstimation.cpp.

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.

Parameters
fromPointsHomogenized points in image 1
toPointsCorresponding homogenized points in image 2
HReturns estimated homography matrix
Author
woelk/frahm

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!

Parameters
fromPointsHomogenized points in image 1
toPointsCorresponding homogenized points in image 2
HReturns estimated affine transformation matrix
Author
koeser 12/2005
Examples:
HMatrixTest.cpp.

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().

int HMatrixEstimation::HErrorFunction_ ( void *  p,
int  m,
int  n,
const double *  x,
double *  fvec,
int  iflag 
)
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.

Attention
Susceptible to local minima, provide good starting point!
Parameters
HHomography matrix to optimize, provides starting point
p1Homogenized points in image 1
p2Corresponding homogenized points in image 2
Returns
Return 0 on success, <0 for errors
Author
koeser 06/2006

Definition at line 52 of file HMatrixEstimation.cpp.

References BIAS::Parametrization::HMatrixToParams(), BIAS::LevenbergMarquardt(), and BIAS::Parametrization::ParamsToHMatrix().

void BIAS::HMatrixEstimation::SetNormalizeHartley ( bool  normalize)
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.

Member Data Documentation

HMatrix BIAS::HMatrixEstimation::H_
protected

Stores the estimated homography matrix (used in GetError)

Definition at line 139 of file HMatrixEstimation.hh.

Normalization BIAS::HMatrixEstimation::normalization_
protected

The normalization algorithm instance.

Definition at line 136 of file HMatrixEstimation.hh.

bool BIAS::HMatrixEstimation::normalizeHartley_
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.

std::vector<BIAS::HomgPoint2D> BIAS::HMatrixEstimation::pointsFrom_
protected

Stores the points in image 1 (used in Optimize and GetError)

Definition at line 142 of file HMatrixEstimation.hh.

Referenced by HErrorFunction_().

std::vector<BIAS::HomgPoint2D> BIAS::HMatrixEstimation::pointsTo_
protected

Stores the points in image 2 (used in Optimize and GetError)

Definition at line 145 of file HMatrixEstimation.hh.

Referenced by HErrorFunction_().


The documentation for this class was generated from the following files: