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 (const vnl_matrix< double > &A, const vnl_vector< double > &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_vector_fixed< double, 4 > *, vnl_vector_fixed< double, 4 > *, vnl_vector_fixed< 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 55 of file PMatrix.h.


Constructor & Destructor Documentation

PMatrix::PMatrix ( )

Constructor. Set up a canonical P matrix.

Definition at line 41 of file PMatrix.cxx.

PMatrix::PMatrix ( vcl_istream &  i)

Construct by loading from vcl_istream.

   PMatrix P(cin);

Definition at line 58 of file PMatrix.cxx.

PMatrix::PMatrix ( const double *  c_matrix)

Construct from row-stored array of 12 doubles.

Definition at line 88 of file PMatrix.cxx.

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

Construct from 3x4 matrix.

Definition at line 68 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 78 of file PMatrix.cxx.

PMatrix::PMatrix ( const PMatrix that)

Definition at line 98 of file PMatrix.cxx.

PMatrix::~PMatrix ( )

Definition at line 114 of file PMatrix.cxx.


Member Function Documentation

HomgLine3D PMatrix::backproject ( const HomgPoint2D x) const

Definition at line 185 of file PMatrix.cxx.

HomgPlane3D PMatrix::backproject ( const HomgLine2D l) const

Definition at line 198 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 180 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 193 of file PMatrix.cxx.

HomgPoint3D PMatrix::backproject_pseudoinverse ( const HomgPoint2D x) const

Definition at line 171 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 165 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 290 of file PMatrix.cxx.

void PMatrix::fix_cheirality ( )

Scale P so determinant of first 3x3 is 1.

Definition at line 564 of file PMatrix.cxx.

void PMatrix::flip_sign ( )

Change the overall sign of the P matrix.

Definition at line 613 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 402 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 425 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 373 of file PMatrix.cxx.

void PMatrix::get ( double *  c_matrix) const

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

Definition at line 382 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 393 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 336 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 299 of file PMatrix.cxx.

HomgPoint3D PMatrix::get_focal_point ( ) const

Definition at line 313 of file PMatrix.cxx.

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

Definition at line 139 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 448 of file PMatrix.cxx.

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

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

Definition at line 470 of file PMatrix.cxx.

bool PMatrix::is_behind_camera ( const HomgPoint3D hX)

Definition at line 598 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 588 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 350 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 622 of file PMatrix.cxx.

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

Definition at line 104 of file PMatrix.cxx.

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

Definition at line 119 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 630 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 636 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 124 of file PMatrix.cxx.

HomgLine2D PMatrix::project ( const HomgLine3D L) const

Definition at line 139 of file PMatrix.cxx.

HomgLineSeg2D PMatrix::project ( const HomgLineSeg3D L) const

Definition at line 155 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 83 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 134 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 148 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 251 of file PMatrix.cxx.

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

Load from vcl_istream.

Definition at line 267 of file PMatrix.cxx.

bool PMatrix::read_ascii ( vcl_istream &  f)

Load from file.

 P.read_ascii("file.P");

Definition at line 227 of file PMatrix.cxx.

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

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

Definition at line 543 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 519 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 494 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 505 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 532 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 279 of file PMatrix.cxx.


Member Data Documentation

Definition at line 146 of file PMatrix.h.

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

Definition at line 147 of file PMatrix.h.


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