A class to hold a Fundamental Matrix of the general form and to perform common operations e.g. More...
#include <FMatrix.h>
Public Member Functions | |
FMatrix () | |
Default constructor. | |
FMatrix (vcl_istream &f) | |
Constructor. Load from vcl_istream. | |
FMatrix (const double *f_matrix) | |
Constructor. | |
FMatrix (const vnl_double_3x3 &f_matrix) | |
Constructor. | |
FMatrix (const PMatrix &P1, const PMatrix &P2) | |
Construct from two P matrices. | |
FMatrix (const PMatrix &P2) | |
Construct from one P matrix, the other is assumed to be [I 0]. | |
FMatrix (const FMatrix &that) | |
virtual | ~FMatrix () |
Destructor. | |
HomgLine2D | image1_epipolar_line (const HomgPoint2D &x2) const |
Return the epipolar line $l_1$ in image 1: $l_1 = F^ x_2$. | |
vgl_homg_line_2d< double > | image1_epipolar_line (vgl_homg_point_2d< double > const &x2) const |
Return the epipolar line $l_1$ in image 1: $l_1 = F^ x_2$. | |
HomgLine2D | image2_epipolar_line (const HomgPoint2D &x1) const |
Return the epipolar line $l_2$ in image 2: $l_2 = F x_1$. | |
vgl_homg_line_2d< double > | image2_epipolar_line (vgl_homg_point_2d< double > const &x1) const |
Return the epipolar line $l_2$ in image 2: $l_2 = F x_1$. | |
double | image1_epipolar_distance_squared (HomgPoint2D *point1_ptr, HomgPoint2D *point2_ptr) const |
double | image1_epipolar_distance_squared (vgl_homg_point_2d< double > const &p1, vgl_homg_point_2d< double > const &p2) const |
double | image2_epipolar_distance_squared (HomgPoint2D *point1_ptr, HomgPoint2D *point2_ptr) const |
double | image2_epipolar_distance_squared (vgl_homg_point_2d< double > const &p1, vgl_homg_point_2d< double > const &p2) const |
void | set_rank2_using_svd () |
Ensure the current Fundamental matrix is rank 2. | |
FMatrix | get_rank2_truncated () |
FMatrix | transpose () const |
Return an FMatrix which corresponds to the reverse of this one. | |
bool | get_epipoles (HomgPoint2D *e1_out, HomgPoint2D *e2_out) const |
Compute the epipoles (left and right nullspaces of F) using vnl_svd<double>. | |
bool | get_epipoles (vgl_homg_point_2d< double > &e1_out, vgl_homg_point_2d< double > &e2_out) const |
Compute the epipoles (left and right nullspaces of F) using vnl_svd<double>. | |
void | decompose_to_skew_rank3 (vnl_matrix< double > *skew, vnl_matrix< double > *rank3) const |
Decompose F to the product of a skew-symmetric matrix and a rank 3 matrix. | |
void | find_nearest_perfect_match (const HomgPoint2D &in1, const HomgPoint2D &in2, HomgPoint2D *out1, HomgPoint2D *out2) const |
Find nearest match which agrees with F. | |
void | find_nearest_perfect_match (vgl_homg_point_2d< double > const &in1, vgl_homg_point_2d< double > const &in2, vgl_homg_point_2d< double > &out1, vgl_homg_point_2d< double > &out2) const |
Find nearest match which agrees with F. | |
void | find_nearest_perfect_match (const HomgPoint2D &in1, const HomgPoint2D &in2, const HomgPoint2D &e1, const HomgPoint2D &e2, HomgPoint2D *out1, HomgPoint2D *out2) const |
Faster Hartley-Sturm using precomputed epipoles. | |
void | find_nearest_perfect_match (vgl_homg_point_2d< double > const &in1, vgl_homg_point_2d< double > const &in2, vgl_homg_point_2d< double > const &e1, vgl_homg_point_2d< double > const &e2, vgl_homg_point_2d< double > &out1, vgl_homg_point_2d< double > &out2) const |
Faster Hartley-Sturm using precomputed epipoles. | |
void | compute_P_matrix (vnl_matrix< double > &P2) const |
void | compute_P_matrix (PMatrix &P2) const |
void | compute_P_matrix (vgl_p_matrix< double > &P2) const |
double | get (unsigned int row_index, unsigned int col_index) const |
Return the element of the matrix at the specified indices (zero-based). | |
virtual bool | set (const double *f_matrix) |
Set the fundamental matrix using the C-storage array c_matrix, and cache the transpose. | |
void | get (double *f_matrix) const |
Copy the fundamental matrix into a 2D array of doubles for `C' compatibility. | |
virtual bool | set (const vnl_double_3x3 &f_matrix) |
Set the fundamental matrix using the vnl_matrix_fixed<double,3,3> f_matrix. | |
void | get (vnl_matrix< double > *f_matrix) const |
Copy the fundamental matrix into a vnl_matrix<double>. | |
void | set (const PMatrix &P1, const PMatrix &P2) |
Set from two P matrices. | |
void | set (const PMatrix &P2) |
Set from one P matrix, the second. The first is assumed to be [I O]. | |
void | set (const FMatrix &) |
Set from another FMatrix: this is just the assignment operator. | |
const vnl_double_3x3 & | get_matrix () const |
Return a const reference to the internal 3x3 matrix. | |
const vnl_double_3x3 & | get_transpose_matrix () const |
Return a const reference to the transpose of the internal 3x3 matrix. | |
bool | get_rank2_flag (void) const |
Return the rank2_flag_. | |
void | set_rank2_flag (bool rank2_flag) |
Set the rank2_flag_. | |
bool | read_ascii (vcl_istream &f) |
Read from ASCII vcl_istream. | |
Static Public Member Functions | |
static FMatrix | read (char const *filename) |
static FMatrix | read (vcl_istream &s) |
Read from ASCII vcl_istream. | |
Protected Attributes | |
vnl_double_3x3 | f_matrix_ |
vnl_double_3x3 | ft_matrix_ |
bool | rank2_flag_ |
Friends | |
vcl_ostream & | operator<< (vcl_ostream &s, const FMatrix &F) |
Print to vcl_ostream. | |
vcl_istream & | operator>> (vcl_istream &s, FMatrix &F) |
Read from ASCII vcl_istream. |
A class to hold a Fundamental Matrix of the general form and to perform common operations e.g.
generate epipolar lines
FMatrix::FMatrix | ( | ) |
Default constructor.
Sets matrices to size 3x3, zero-filled.
Definition at line 32 of file FMatrix.cxx.
FMatrix::FMatrix | ( | vcl_istream & | f | ) |
Constructor. Load from vcl_istream.
Definition at line 41 of file FMatrix.cxx.
FMatrix::FMatrix | ( | const double * | f_matrix | ) |
Constructor.
Definition at line 51 of file FMatrix.cxx.
FMatrix::FMatrix | ( | const vnl_double_3x3 & | f_matrix | ) |
Constructor.
Definition at line 61 of file FMatrix.cxx.
Construct from two P matrices.
Definition at line 72 of file FMatrix.cxx.
FMatrix::FMatrix | ( | const PMatrix & | P2 | ) |
Construct from one P matrix, the other is assumed to be [I 0].
Definition at line 82 of file FMatrix.cxx.
FMatrix::~FMatrix | ( | ) | [virtual] |
Destructor.
Definition at line 91 of file FMatrix.cxx.
void FMatrix::compute_P_matrix | ( | vnl_matrix< double > & | P2 | ) | const |
Definition at line 561 of file FMatrix.cxx.
void FMatrix::compute_P_matrix | ( | PMatrix & | P2 | ) | const [inline] |
void FMatrix::compute_P_matrix | ( | vgl_p_matrix< double > & | P2 | ) | const [inline] |
void FMatrix::decompose_to_skew_rank3 | ( | vnl_matrix< double > * | skew, |
vnl_matrix< double > * | rank3 | ||
) | const |
Decompose F to the product of a skew-symmetric matrix and a rank 3 matrix.
Reimplemented in FMatrixSkew.
Definition at line 597 of file FMatrix.cxx.
void FMatrix::find_nearest_perfect_match | ( | const HomgPoint2D & | point1, |
const HomgPoint2D & | point2, | ||
HomgPoint2D * | perfect_point1_ptr, | ||
HomgPoint2D * | perfect_point2_ptr | ||
) | const |
Find nearest match which agrees with F.
For a specified pair of matching points, find the nearest (minimum sum of squared image distances) match which is in perfect agreement with the epipolar geometry of the F matrix. (see R.I. Hartley and P. Sturm, ``Triangulation''. In {Proceedings, Computer Analysis of Images and Patterns}, Prague, 1995).
Reimplemented in FMatrixSkew, and FMatrixPlanar.
Definition at line 313 of file FMatrix.cxx.
void FMatrix::find_nearest_perfect_match | ( | vgl_homg_point_2d< double > const & | point1, |
vgl_homg_point_2d< double > const & | point2, | ||
vgl_homg_point_2d< double > & | perfect_point1, | ||
vgl_homg_point_2d< double > & | perfect_point2 | ||
) | const |
Find nearest match which agrees with F.
For a specified pair of matching points, find the nearest (minimum sum of squared image distances) match which is in perfect agreement with the epipolar geometry of the F matrix. (see R.I. Hartley and P. Sturm, ``Triangulation''. In {Proceedings, Computer Analysis of Images and Patterns}, Prague, 1995).
Reimplemented in FMatrixSkew, and FMatrixPlanar.
Definition at line 291 of file FMatrix.cxx.
void FMatrix::find_nearest_perfect_match | ( | const HomgPoint2D & | in1, |
const HomgPoint2D & | in2, | ||
const HomgPoint2D & | e1, | ||
const HomgPoint2D & | e2, | ||
HomgPoint2D * | out1, | ||
HomgPoint2D * | out2 | ||
) | const |
Faster Hartley-Sturm using precomputed epipoles.
Definition at line 441 of file FMatrix.cxx.
void FMatrix::find_nearest_perfect_match | ( | vgl_homg_point_2d< double > const & | in1, |
vgl_homg_point_2d< double > const & | in2, | ||
vgl_homg_point_2d< double > const & | e1, | ||
vgl_homg_point_2d< double > const & | e2, | ||
vgl_homg_point_2d< double > & | out1, | ||
vgl_homg_point_2d< double > & | out2 | ||
) | const |
Faster Hartley-Sturm using precomputed epipoles.
Definition at line 326 of file FMatrix.cxx.
double FMatrix::get | ( | unsigned int | row_index, |
unsigned int | col_index | ||
) | const |
Return the element of the matrix at the specified indices (zero-based).
Definition at line 607 of file FMatrix.cxx.
void FMatrix::get | ( | double * | f_matrix | ) | const |
Copy the fundamental matrix into a 2D array of doubles for `C' compatibility.
Definition at line 616 of file FMatrix.cxx.
void FMatrix::get | ( | vnl_matrix< double > * | f_matrix | ) | const |
Copy the fundamental matrix into a vnl_matrix<double>.
Definition at line 626 of file FMatrix.cxx.
bool FMatrix::get_epipoles | ( | HomgPoint2D * | epipole1_ptr, |
HomgPoint2D * | epipole2_ptr | ||
) | const |
Compute the epipoles (left and right nullspaces of F) using vnl_svd<double>.
Return false if the rank of F is not 2, and set approximate epipoles, (the left and right singular vectors corresponding to the smallest singular value of F).
Reimplemented in FMatrixSkew.
Definition at line 270 of file FMatrix.cxx.
bool FMatrix::get_epipoles | ( | vgl_homg_point_2d< double > & | epipole1, |
vgl_homg_point_2d< double > & | epipole2 | ||
) | const |
Compute the epipoles (left and right nullspaces of F) using vnl_svd<double>.
Return false if the rank of F is not 2, and set approximate epipoles, (the left and right singular vectors corresponding to the smallest singular value of F).
Reimplemented in FMatrixSkew.
Definition at line 252 of file FMatrix.cxx.
const vnl_double_3x3& FMatrix::get_matrix | ( | ) | const [inline] |
bool FMatrix::get_rank2_flag | ( | void | ) | const |
Return the rank2_flag_.
Reimplemented in FMatrixSkew, and FMatrixPlanar.
Definition at line 635 of file FMatrix.cxx.
FMatrix FMatrix::get_rank2_truncated | ( | ) |
Reimplemented in FMatrixPlanar, and FMatrixSkew.
const vnl_double_3x3& FMatrix::get_transpose_matrix | ( | ) | const [inline] |
double FMatrix::image1_epipolar_distance_squared | ( | HomgPoint2D * | point1_ptr, |
HomgPoint2D * | point2_ptr | ||
) | const |
Definition at line 191 of file FMatrix.cxx.
double FMatrix::image1_epipolar_distance_squared | ( | vgl_homg_point_2d< double > const & | p1, |
vgl_homg_point_2d< double > const & | p2 | ||
) | const |
Definition at line 178 of file FMatrix.cxx.
HomgLine2D FMatrix::image1_epipolar_line | ( | const HomgPoint2D & | x2 | ) | const |
Return the epipolar line $l_1$ in image 1: $l_1 = F^ x_2$.
Definition at line 148 of file FMatrix.cxx.
vgl_homg_line_2d< double > FMatrix::image1_epipolar_line | ( | vgl_homg_point_2d< double > const & | x2 | ) | const |
Return the epipolar line $l_1$ in image 1: $l_1 = F^ x_2$.
Definition at line 139 of file FMatrix.cxx.
double FMatrix::image2_epipolar_distance_squared | ( | HomgPoint2D * | point1_ptr, |
HomgPoint2D * | point2_ptr | ||
) | const |
Definition at line 217 of file FMatrix.cxx.
double FMatrix::image2_epipolar_distance_squared | ( | vgl_homg_point_2d< double > const & | p1, |
vgl_homg_point_2d< double > const & | p2 | ||
) | const |
Definition at line 204 of file FMatrix.cxx.
HomgLine2D FMatrix::image2_epipolar_line | ( | const HomgPoint2D & | x1 | ) | const |
Return the epipolar line $l_2$ in image 2: $l_2 = F x_1$.
Definition at line 167 of file FMatrix.cxx.
vgl_homg_line_2d< double > FMatrix::image2_epipolar_line | ( | vgl_homg_point_2d< double > const & | x1 | ) | const |
Return the epipolar line $l_2$ in image 2: $l_2 = F x_1$.
Definition at line 157 of file FMatrix.cxx.
FMatrix FMatrix::read | ( | char const * | filename | ) | [static] |
Definition at line 110 of file FMatrix.cxx.
FMatrix FMatrix::read | ( | vcl_istream & | s | ) | [static] |
Read from ASCII vcl_istream.
Definition at line 129 of file FMatrix.cxx.
bool FMatrix::read_ascii | ( | vcl_istream & | f | ) |
Read from ASCII vcl_istream.
Definition at line 97 of file FMatrix.cxx.
bool FMatrix::set | ( | const double * | c_matrix | ) | [virtual] |
Set the fundamental matrix using the C-storage array c_matrix, and cache the transpose.
Always returns true for the base class - showing the set was a success. When overridden by derived classes it may return false, to indicate that the matrix violates the constraints imposed by the derived classes.
Reimplemented in FMatrixSkew, FMatrixPlanar, and FMatrixAffine.
Definition at line 656 of file FMatrix.cxx.
bool FMatrix::set | ( | const vnl_double_3x3 & | f_matrix | ) | [virtual] |
Set the fundamental matrix using the vnl_matrix_fixed<double,3,3> f_matrix.
Always returns true for the base class - showing the set was a success. When overridden by derived classes it may return false, to indicate that the matrix violates the constraints imposed by the derived classes.
Reimplemented in FMatrixPlanar.
Definition at line 675 of file FMatrix.cxx.
Set from two P matrices.
Definition at line 684 of file FMatrix.cxx.
void FMatrix::set | ( | const PMatrix & | P2 | ) |
Set from one P matrix, the second. The first is assumed to be [I O].
Definition at line 694 of file FMatrix.cxx.
void FMatrix::set | ( | const FMatrix & | F | ) |
Set from another FMatrix: this is just the assignment operator.
Definition at line 706 of file FMatrix.cxx.
void FMatrix::set_rank2_flag | ( | bool | rank2_flag | ) |
void FMatrix::set_rank2_using_svd | ( | void | ) |
Ensure the current Fundamental matrix is rank 2.
Does this by taking its vnl_svd<double>, setting the smallest singular value to zero, and recomposing. Sets the rank2_flag_ to true.
Reimplemented in FMatrixPlanar, and FMatrixSkew.
Definition at line 582 of file FMatrix.cxx.
FMatrix FMatrix::transpose | ( | ) | const |
Return an FMatrix which corresponds to the reverse of this one.
Definition at line 241 of file FMatrix.cxx.
vcl_ostream& operator<< | ( | vcl_ostream & | s, |
const FMatrix & | F | ||
) | [friend] |
Print to vcl_ostream.
Definition at line 226 of file FMatrix.cxx.
vcl_istream& operator>> | ( | vcl_istream & | s, |
FMatrix & | F | ||
) | [friend] |
Read from ASCII vcl_istream.
Definition at line 121 of file FMatrix.cxx.
vnl_double_3x3 FMatrix::f_matrix_ [protected] |
vnl_double_3x3 FMatrix::ft_matrix_ [protected] |
bool FMatrix::rank2_flag_ [protected] |