Public Member Functions | Static Public Member Functions | Protected Attributes
PMatrix Class Reference

#include <PMatrix.h>

Inheritance diagram for PMatrix:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 PMatrix ()
 Constructor. Set up a canonical P matrix.
 PMatrix (vcl_istream &)
 Construct by loading from vcl_istream.
 PMatrix (const double *c_matrix)
 Construct from row-stored array of 12 doubles.
 PMatrix (vnl_double_3x4 const &)
 Construct from 3x4 matrix.
 PMatrix (const vnl_matrix< double > &A, const vnl_vector< double > &a)
 Construct from 3x3 matrix A and vector a. P = [A a].
 PMatrix (const PMatrix &)
 ~PMatrix ()
HomgPoint2D project (const HomgPoint3D &X) const
 Return the image point which is the projection of the specified 3D point X.
HomgLine2D project (const HomgLine3D &L) const
HomgLineSeg2D project (const HomgLineSeg3D &L) const
HomgPoint3D backproject_pseudoinverse (const HomgPoint2D &x) const
HomgLine3D backproject (const HomgPoint2D &x) const
HomgPlane3D backproject (const HomgLine2D &l) const
vgl_homg_point_2d< double > project (vgl_homg_point_3d< double > const &X) const
 Return the image point which is the projection of the specified 3D point X.
vgl_homg_line_2d< double > project (vgl_homg_line_3d_2_points< double > const &L) const
 Return the image line which is the projection of the specified 3D line L.
vgl_line_segment_2d< double > project (vgl_line_segment_3d< double > const &L) const
 Return the image linesegment which is the projection of the specified 3D linesegment L.
vgl_homg_point_3d< double > backproject_pseudoinverse (vgl_homg_point_2d< double > const &x) const
 Return the 3D point $ X$ which is $ X = P^+ x$.
vgl_homg_line_3d_2_points< double > backproject (vgl_homg_point_2d< double > const &x) const
 Return the 3D line which is the backprojection of the specified image point, x.
vgl_homg_plane_3d< double > backproject (vgl_homg_line_2d< double > const &l) const
 Return the 3D plane which is the backprojection of the specified line l in the image.
PMatrix postmultiply (vnl_double_4x4 const &H) const
 post-multiply this projection matrix with a HMatrix3D.
PMatrix premultiply (vnl_double_3x3 const &H) const
 pre-multiply this projection matrix with a HMatrix2D.
vnl_svd< double > * svd () const
 Compute the svd of this P and cache it, so that future operations that require it need not recompute it.
void clear_svd () const
 Discredit the cached svd.
HomgPoint3D get_focal_point () const
vgl_homg_point_3d< double > get_focal () const
 Return the 3D point representing the focal point of the camera.
HMatrix3D get_canonical_H () const
 Return the HMatrix3D s.t. P * H = [I 0].
bool is_canonical (double tol=0) const
 Return true iff P is [I 0].
bool is_behind_camera (const HomgPoint3D &)
bool is_behind_camera (vgl_homg_point_3d< double > const &)
 Return true if the 3D point X is behind the camera represented by this P.
void flip_sign ()
 Change the overall sign of the P matrix.
bool looks_conditioned ()
 Splendid hack that tries to detect if the P is an image-coords P or a normalized P.
void fix_cheirality ()
 Scale P so determinant of first 3x3 is 1.
PMatrixoperator= (const PMatrix &)
bool operator== (PMatrix const &p) const
void get (vnl_matrix< double > *A, vnl_vector< double > *a) const
 Return the 3x3 matrix and 3x1 column vector of P = [A a].
void get (vnl_double_3x3 *A, vnl_double_3 *a) const
 Return the 3x3 matrix and 3x1 column vector of P = [A a].
void set (vnl_double_3x3 const &A, vnl_double_3 const &a)
 Set from 3x3 matrix and 3x1 column vector of P = [A a].
void get_rows (vnl_vector< double > *, vnl_vector< double > *, vnl_vector< double > *) const
 Return the rows of P = [a b c]'.
void get_rows (vnl_double_4 *, vnl_double_4 *, vnl_double_4 *) const
 Return the rows of P = [a b c]'.
void set_rows (const vnl_vector< double > &, const vnl_vector< double > &, const vnl_vector< double > &)
double get (unsigned int row_index, unsigned int col_index) const
 Return the element of the matrix at the specified indices.
void get (double *c_matrix) const
 Return the 3x4 projection matrix in the array, p_matrix.
void get (vnl_matrix< double > *p_matrix) const
void get (vnl_double_3x4 *p_matrix) const
 Return the 3x4 projection matrix in the vnl_matrix<double>, p_matrix.
void set (const double *p_matrix)
 Set the 3x4 projective matrix with the matrix in the array, p_matrix.
void set (const double p_matrix[3][4])
 Set the 3x4 projective matrix with the matrix in the array, p_matrix.
void set (const vnl_matrix< double > &p_matrix)
 Set the 3x4 projective matrix with the matrix in the array, p_matrix.
void set (vnl_double_3x4 const &p_matrix)
 Set the fundamental matrix using the vnl_matrix<double> p_matrix.
const vnl_double_3x4get_matrix () const
bool read_ascii (vcl_istream &f)
 Load from file.
void ref ()
void unref ()
int get_references () const
bool is_referenced () const

Static Public Member Functions

static PMatrix read (const char *filename)
 Load from file.
static PMatrix read (vcl_istream &)
 Load from vcl_istream.

Protected Attributes

vnl_double_3x4 p_matrix_
vnl_svd< double > * svd_

Detailed Description

Definition at line 56 of file PMatrix.h.


Constructor & Destructor Documentation

PMatrix::PMatrix ( )

Constructor. Set up a canonical P matrix.

Definition at line 40 of file PMatrix.cxx.

PMatrix::PMatrix ( vcl_istream &  i)

Construct by loading from vcl_istream.

   PMatrix P(cin);

Definition at line 57 of file PMatrix.cxx.

PMatrix::PMatrix ( const double *  c_matrix)

Construct from row-stored array of 12 doubles.

Definition at line 87 of file PMatrix.cxx.

PMatrix::PMatrix ( vnl_double_3x4 const &  pmatrix) [explicit]

Construct from 3x4 matrix.

Definition at line 67 of file PMatrix.cxx.

PMatrix::PMatrix ( const vnl_matrix< double > &  A,
const vnl_vector< double > &  a 
)

Construct from 3x3 matrix A and vector a. P = [A a].

Definition at line 77 of file PMatrix.cxx.

PMatrix::PMatrix ( const PMatrix that)

Definition at line 97 of file PMatrix.cxx.

PMatrix::~PMatrix ( )

Definition at line 113 of file PMatrix.cxx.


Member Function Documentation

HomgLine3D PMatrix::backproject ( const HomgPoint2D x) const

Definition at line 184 of file PMatrix.cxx.

HomgPlane3D PMatrix::backproject ( const HomgLine2D l) const

Definition at line 197 of file PMatrix.cxx.

vgl_homg_line_3d_2_points< double > PMatrix::backproject ( vgl_homg_point_2d< double > const &  x) const

Return the 3D line which is the backprojection of the specified image point, x.

Uses svd().

Definition at line 179 of file PMatrix.cxx.

vgl_homg_plane_3d< double > PMatrix::backproject ( vgl_homg_line_2d< double > const &  l) const

Return the 3D plane which is the backprojection of the specified line l in the image.

Definition at line 192 of file PMatrix.cxx.

HomgPoint3D PMatrix::backproject_pseudoinverse ( const HomgPoint2D x) const

Definition at line 170 of file PMatrix.cxx.

vgl_homg_point_3d< double > PMatrix::backproject_pseudoinverse ( vgl_homg_point_2d< double > const &  x) const

Return the 3D point $ X$ which is $ X = P^+ x$.

Equivalently, the 3D point of smallest norm such that $P \vec X = \vec x$. Uses svd().

Definition at line 164 of file PMatrix.cxx.

void PMatrix::clear_svd ( ) const

Discredit the cached svd.

This is necessary only in order to recover the space used by it if the PMatrix is not being deleted.

Definition at line 289 of file PMatrix.cxx.

void PMatrix::fix_cheirality ( )

Scale P so determinant of first 3x3 is 1.

Definition at line 563 of file PMatrix.cxx.

void PMatrix::flip_sign ( )

Change the overall sign of the P matrix.

Definition at line 612 of file PMatrix.cxx.

void PMatrix::get ( vnl_matrix< double > *  A,
vnl_vector< double > *  a 
) const

Return the 3x3 matrix and 3x1 column vector of P = [A a].

Definition at line 401 of file PMatrix.cxx.

void PMatrix::get ( vnl_double_3x3 A,
vnl_double_3 *  a 
) const

Return the 3x3 matrix and 3x1 column vector of P = [A a].

Definition at line 424 of file PMatrix.cxx.

double PMatrix::get ( unsigned int  row_index,
unsigned int  col_index 
) const

Return the element of the matrix at the specified indices.

Definition at line 372 of file PMatrix.cxx.

void PMatrix::get ( double *  c_matrix) const

Return the 3x4 projection matrix in the array, p_matrix.

Definition at line 381 of file PMatrix.cxx.

void PMatrix::get ( vnl_matrix< double > *  p_matrix) const
void PMatrix::get ( vnl_double_3x4 p_matrix) const

Return the 3x4 projection matrix in the vnl_matrix<double>, p_matrix.

Definition at line 392 of file PMatrix.cxx.

HMatrix3D PMatrix::get_canonical_H ( ) const

Return the HMatrix3D s.t. P * H = [I 0].

If P = [A a], then H = [inv(A) -inv(A)*a; 0 0 0 1];

Definition at line 335 of file PMatrix.cxx.

vgl_homg_point_3d< double > PMatrix::get_focal ( ) const

Return the 3D point representing the focal point of the camera.

Uses svd().

Definition at line 298 of file PMatrix.cxx.

HomgPoint3D PMatrix::get_focal_point ( ) const

Definition at line 312 of file PMatrix.cxx.

const vnl_double_3x4& PMatrix::get_matrix ( ) const [inline]

Definition at line 140 of file PMatrix.h.

void PMatrix::get_rows ( vnl_vector< double > *  a,
vnl_vector< double > *  b,
vnl_vector< double > *  c 
) const

Return the rows of P = [a b c]'.

Definition at line 447 of file PMatrix.cxx.

void PMatrix::get_rows ( vnl_double_4 *  a,
vnl_double_4 *  b,
vnl_double_4 *  c 
) const

Return the rows of P = [a b c]'.

Definition at line 469 of file PMatrix.cxx.

bool PMatrix::is_behind_camera ( const HomgPoint3D hX)

Definition at line 597 of file PMatrix.cxx.

bool PMatrix::is_behind_camera ( vgl_homg_point_3d< double > const &  hX)

Return true if the 3D point X is behind the camera represented by this P.

This depends on the overall sign of the P matrix having been set correctly, a la Hartley cheirality paper.

Definition at line 587 of file PMatrix.cxx.

bool PMatrix::is_canonical ( double  tol = 0) const

Return true iff P is [I 0].

Equality is assumed if the max abs diff is less than tol.

Definition at line 349 of file PMatrix.cxx.

bool PMatrix::looks_conditioned ( )

Splendid hack that tries to detect if the P is an image-coords P or a normalized P.

Definition at line 621 of file PMatrix.cxx.

PMatrix & PMatrix::operator= ( const PMatrix that)

Definition at line 103 of file PMatrix.cxx.

bool PMatrix::operator== ( PMatrix const &  p) const [inline]

Definition at line 120 of file PMatrix.h.

PMatrix PMatrix::postmultiply ( vnl_double_4x4 const &  H) const

post-multiply this projection matrix with a HMatrix3D.

Postmultiply by 4x4 matrix.

Definition at line 629 of file PMatrix.cxx.

PMatrix PMatrix::premultiply ( vnl_double_3x3 const &  H) const

pre-multiply this projection matrix with a HMatrix2D.

Premultiply by 3x3 matrix.

Definition at line 635 of file PMatrix.cxx.

HomgPoint2D PMatrix::project ( const HomgPoint3D X) const

Return the image point which is the projection of the specified 3D point X.

Definition at line 123 of file PMatrix.cxx.

HomgLine2D PMatrix::project ( const HomgLine3D L) const

Definition at line 138 of file PMatrix.cxx.

HomgLineSeg2D PMatrix::project ( const HomgLineSeg3D L) const

Definition at line 154 of file PMatrix.cxx.

vgl_homg_point_2d<double> PMatrix::project ( vgl_homg_point_3d< double > const &  X) const [inline]

Return the image point which is the projection of the specified 3D point X.

Definition at line 84 of file PMatrix.h.

vgl_homg_line_2d< double > PMatrix::project ( vgl_homg_line_3d_2_points< double > const &  L) const

Return the image line which is the projection of the specified 3D line L.

Definition at line 133 of file PMatrix.cxx.

vgl_line_segment_2d< double > PMatrix::project ( vgl_line_segment_3d< double > const &  L) const

Return the image linesegment which is the projection of the specified 3D linesegment L.

Definition at line 147 of file PMatrix.cxx.

PMatrix PMatrix::read ( const char *  filename) [static]

Load from file.

Static method, so you can say

 PMatrix P = PMatrix::read("file.P");

Definition at line 250 of file PMatrix.cxx.

PMatrix PMatrix::read ( vcl_istream &  s) [static]

Load from vcl_istream.

Definition at line 266 of file PMatrix.cxx.

bool PMatrix::read_ascii ( vcl_istream &  f)

Load from file.

 P.read_ascii("file.P");

Definition at line 226 of file PMatrix.cxx.

void PMatrix::set ( vnl_double_3x3 const &  A,
vnl_double_3 const &  a 
)

Set from 3x3 matrix and 3x1 column vector of P = [A a].

Definition at line 542 of file PMatrix.cxx.

void PMatrix::set ( const double *  p_matrix)

Set the 3x4 projective matrix with the matrix in the array, p_matrix.

Definition at line 518 of file PMatrix.cxx.

void PMatrix::set ( const double  p_matrix[3][4])

Set the 3x4 projective matrix with the matrix in the array, p_matrix.

Definition at line 493 of file PMatrix.cxx.

void PMatrix::set ( const vnl_matrix< double > &  p_matrix)

Set the 3x4 projective matrix with the matrix in the array, p_matrix.

Definition at line 504 of file PMatrix.cxx.

void PMatrix::set ( vnl_double_3x4 const &  p_matrix)

Set the fundamental matrix using the vnl_matrix<double> p_matrix.

Definition at line 531 of file PMatrix.cxx.

void PMatrix::set_rows ( const vnl_vector< double > &  ,
const vnl_vector< double > &  ,
const vnl_vector< double > &   
)
vnl_svd< double > * PMatrix::svd ( ) const

Compute the svd of this P and cache it, so that future operations that require it need not recompute it.

Definition at line 278 of file PMatrix.cxx.


Member Data Documentation

Definition at line 147 of file PMatrix.h.

vnl_svd<double>* PMatrix::svd_ [mutable, protected]

Definition at line 148 of file PMatrix.h.


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