Public Member Functions | Static Public Member Functions | Protected Attributes
vgl_p_matrix< T > Class Template Reference

#include <vgl_p_matrix.h>

List of all members.

Public Member Functions

 vgl_p_matrix ()
 Constructor. Set up a canonical P matrix.
 vgl_p_matrix (vcl_istream &)
 Construct by loading from vcl_istream.
 vgl_p_matrix (const T *c_matrix)
 Construct from row-stored C-array of 12 elements.
 vgl_p_matrix (vnl_matrix_fixed< T, 3, 4 > const &P)
 Construct from 3x4 matrix.
 vgl_p_matrix (const vnl_matrix_fixed< T, 3, 3 > &A, const vnl_vector_fixed< T, 3 > &a)
 Construct from 3x3 matrix A and vector a. P = [A a].
 vgl_p_matrix (const vnl_matrix< T > &A, const vnl_vector< T > &a)
 Deprecated; use the vnl_matrix_fixed variant instead.
 vgl_p_matrix (const vgl_p_matrix &P)
 ~vgl_p_matrix ()
vgl_homg_point_2d< T > operator() (vgl_homg_point_3d< T > const &X) const
 Return the image point which is the projection of the specified 3D point X.
vgl_homg_point_2d< T > operator* (vgl_homg_point_3d< T > const &X) const
 Return the image point which is the projection of the specified 3D point X.
vgl_homg_line_2d< T > operator() (vgl_homg_line_3d_2_points< T > const &L) const
 Return the image line which is the projection of the specified 3D line L.
vgl_homg_line_2d< T > operator* (vgl_homg_line_3d_2_points< T > const &L) const
 Return the image line which is the projection of the specified 3D line L.
vgl_line_segment_2d< T > operator() (vgl_line_segment_3d< T > const &L) const
 Return the image linesegment which is the projection of the specified 3D linesegment L.
vgl_line_segment_2d< T > operator* (vgl_line_segment_3d< T > const &L) const
 Return the image linesegment which is the projection of the specified 3D linesegment L.
vgl_homg_point_3d< T > backproject_pseudoinverse (vgl_homg_point_2d< T > const &x) const
 Return the 3D point $ X$ which is $ X = P^+ x$.
vgl_homg_line_3d_2_points< T > backproject (vgl_homg_point_2d< T > const &x) const
 Return the 3D line which is the backprojection of the specified image point, x.
vgl_homg_plane_3d< T > backproject (vgl_homg_line_2d< T > const &l) const
 Return the 3D plane which is the backprojection of the specified line l in the image.
vgl_p_matrix< T > postmultiply (vnl_matrix_fixed< T, 4, 4 > const &H) const
 post-multiply this projection matrix with a 3-d projective transform.
vgl_p_matrix< T > premultiply (vnl_matrix_fixed< T, 3, 3 > const &H) const
 pre-multiply this projection matrix with a 2-d projective transform.
vgl_p_matrix< T > operator* (vnl_matrix_fixed< T, 3, 3 > const &C) const
 pre-multiply this projection matrix with a 2-d projective transform.
vnl_svd< T > * 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.
vgl_homg_point_3d< T > get_focal () const
 Return the 3D point representing the focal point of the camera.
vgl_h_matrix_3d< T > get_canonical_H () const
 Return the 3D H-matrix s.t. P * H = [I 0].
bool is_canonical (T tol=0) const
 Return true iff P is [I 0].
bool is_behind_camera (vgl_homg_point_3d< T > const &)
 Return true if the 3D point X is behind the camera represented by this P.
vgl_p_matrixflip_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.
vgl_p_matrixfix_cheirality ()
 Scale P so determinant of first 3x3 is 1.
vgl_p_matrixoperator= (const vgl_p_matrix &)
bool operator== (vgl_p_matrix const &p) const
void get (vnl_matrix_fixed< T, 3, 3 > *A, vnl_vector_fixed< T, 3 > *a) const
 Return the 3x3 matrix and 3x1 column vector of P = [A a].
void get (vnl_matrix< T > *A, vnl_vector< T > *a) const
 Deprecated; use the vnl_matrix_fixed variant instead.
void get_rows (vnl_vector< T > *a, vnl_vector< T > *b, vnl_vector< T > *c) const
 Return the rows of P = [a b c]'.
void get_rows (vnl_vector_fixed< T, 4 > *a, vnl_vector_fixed< T, 4 > *b, vnl_vector_fixed< T, 4 > *c) const
 Return the rows of P = [a b c]'.
vgl_p_matrixset_rows (const vnl_vector_fixed< T, 4 > &a, const vnl_vector_fixed< T, 4 > &b, const vnl_vector_fixed< T, 4 > &c)
 Set P = [a b c]' from its rows a, b, c.
get (unsigned int row_index, unsigned int col_index) const
 Return the element of the matrix at the specified index pair.
void get (T *c_matrix) const
 Return the 3x4 projection matrix in the C-array, c_matrix.
void get (vnl_matrix_fixed< T, 3, 4 > &p_matrix) const
 Return the 3x4 projection matrix in p_matrix.
void get (vnl_matrix< T > &p_matrix) const
 Deprecated; use the vnl_matrix_fixed variant instead.
vgl_p_matrixset (vnl_matrix_fixed< T, 3, 4 > const &p_matrix)
 Set the internal matrix using the 3x4 p_matrix.
vgl_p_matrixset (const vnl_matrix< T > &p_matrix)
 Deprecated; use the vnl_matrix_fixed variant instead.
vgl_p_matrixset (vnl_matrix_fixed< T, 3, 3 > const &A, vnl_vector_fixed< T, 3 > const &a)
 Set from 3x3 matrix and 3x1 column vector of P = [A a].
vgl_p_matrixset (vnl_matrix< T > const &A, vnl_vector< T > const &a)
 Deprecated; use the vnl_matrix_fixed variant instead.
vgl_p_matrixset (const T *p_matrix)
 Set the projective matrix with the matrix in the 3x4 C-array, p_matrix.
vgl_p_matrixset (const T p_matrix[3][4])
 Set the projective matrix with the matrix in the 3x4 C-array, p_matrix.
const vnl_matrix_fixed< T, 3, 4 > & get_matrix () const
vgl_p_matrixset_identity ()
 Set the camera to an identity projection. X->u, Y->v.
bool read_ascii (vcl_istream &f)
 Load from file.

Static Public Member Functions

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

Protected Attributes

vnl_matrix_fixed< T, 3, 4 > p_matrix_
vnl_svd< T > * svd_

Detailed Description

template<class T>
class vgl_p_matrix< T >

Definition at line 47 of file vgl_p_matrix.h.


Constructor & Destructor Documentation

template<class T >
vgl_p_matrix< T >::vgl_p_matrix ( )

Constructor. Set up a canonical P matrix.

Definition at line 23 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T >::vgl_p_matrix ( vcl_istream &  i)

Construct by loading from vcl_istream.

   vgl_p_matrix P(cin);

Definition at line 37 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T >::vgl_p_matrix ( const T *  c_matrix)

Construct from row-stored C-array of 12 elements.

Definition at line 54 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T >::vgl_p_matrix ( vnl_matrix_fixed< T, 3, 4 > const &  P) [explicit]

Construct from 3x4 matrix.

Definition at line 46 of file vgl_p_matrix.txx.

template<class T>
vgl_p_matrix< T >::vgl_p_matrix ( const vnl_matrix_fixed< T, 3, 3 > &  A,
const vnl_vector_fixed< T, 3 > &  a 
) [inline]

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

Definition at line 65 of file vgl_p_matrix.h.

template<class T>
vgl_p_matrix< T >::vgl_p_matrix ( const vnl_matrix< T > &  A,
const vnl_vector< T > &  a 
) [inline]

Deprecated; use the vnl_matrix_fixed variant instead.

Definition at line 68 of file vgl_p_matrix.h.

template<class T >
vgl_p_matrix< T >::vgl_p_matrix ( const vgl_p_matrix< T > &  P)

Definition at line 63 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T >::~vgl_p_matrix ( )

Definition at line 81 of file vgl_p_matrix.txx.


Member Function Documentation

template<class T >
vgl_homg_line_3d_2_points< T > vgl_p_matrix< T >::backproject ( vgl_homg_point_2d< T > const &  x) const

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

Uses svd().

Definition at line 119 of file vgl_p_matrix.txx.

template<class T >
vgl_homg_plane_3d< T > vgl_p_matrix< T >::backproject ( vgl_homg_line_2d< T > const &  l) const

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

Definition at line 127 of file vgl_p_matrix.txx.

template<class T >
vgl_homg_point_3d< T > vgl_p_matrix< T >::backproject_pseudoinverse ( vgl_homg_point_2d< T > 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 110 of file vgl_p_matrix.txx.

template<class T >
void vgl_p_matrix< T >::clear_svd ( ) const

Discredit the cached svd.

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

Definition at line 202 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::fix_cheirality ( )

Scale P so determinant of first 3x3 is 1.

Definition at line 479 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::flip_sign ( )

Change the overall sign of the P matrix.

Definition at line 516 of file vgl_p_matrix.txx.

template<class T >
void vgl_p_matrix< T >::get ( vnl_matrix_fixed< T, 3, 3 > *  A,
vnl_vector_fixed< T, 3 > *  a 
) const

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

Definition at line 299 of file vgl_p_matrix.txx.

template<class T >
void vgl_p_matrix< T >::get ( vnl_matrix< T > *  A,
vnl_vector< T > *  a 
) const

Deprecated; use the vnl_matrix_fixed variant instead.

Definition at line 276 of file vgl_p_matrix.txx.

template<class T >
T vgl_p_matrix< T >::get ( unsigned int  row_index,
unsigned int  col_index 
) const

Return the element of the matrix at the specified index pair.

Definition at line 257 of file vgl_p_matrix.txx.

template<class T >
void vgl_p_matrix< T >::get ( T *  c_matrix) const

Return the 3x4 projection matrix in the C-array, c_matrix.

Definition at line 265 of file vgl_p_matrix.txx.

template<class T>
void vgl_p_matrix< T >::get ( vnl_matrix_fixed< T, 3, 4 > &  p_matrix) const [inline]

Return the 3x4 projection matrix in p_matrix.

Definition at line 167 of file vgl_p_matrix.h.

template<class T>
void vgl_p_matrix< T >::get ( vnl_matrix< T > &  p_matrix) const [inline]

Deprecated; use the vnl_matrix_fixed variant instead.

Definition at line 169 of file vgl_p_matrix.h.

template<class T >
vgl_h_matrix_3d< T > vgl_p_matrix< T >::get_canonical_H ( ) const

Return the 3D H-matrix s.t. P * H = [I 0].

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

Definition at line 225 of file vgl_p_matrix.txx.

template<class T >
vgl_homg_point_3d< T > vgl_p_matrix< T >::get_focal ( ) const

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

Uses svd().

Definition at line 210 of file vgl_p_matrix.txx.

template<class T>
const vnl_matrix_fixed<T, 3, 4>& vgl_p_matrix< T >::get_matrix ( ) const [inline]

Definition at line 184 of file vgl_p_matrix.h.

template<class T >
void vgl_p_matrix< T >::get_rows ( vnl_vector< T > *  a,
vnl_vector< T > *  b,
vnl_vector< T > *  c 
) const

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

Definition at line 322 of file vgl_p_matrix.txx.

template<class T >
void vgl_p_matrix< T >::get_rows ( vnl_vector_fixed< T, 4 > *  a,
vnl_vector_fixed< T, 4 > *  b,
vnl_vector_fixed< T, 4 > *  c 
) const

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

Definition at line 347 of file vgl_p_matrix.txx.

template<class T >
bool vgl_p_matrix< T >::is_behind_camera ( vgl_homg_point_3d< T > 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 505 of file vgl_p_matrix.txx.

template<class T >
bool vgl_p_matrix< T >::is_canonical ( 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 234 of file vgl_p_matrix.txx.

template<class T >
bool vgl_p_matrix< T >::looks_conditioned ( )

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

Definition at line 525 of file vgl_p_matrix.txx.

template<class T>
vgl_homg_point_2d<T> vgl_p_matrix< T >::operator() ( vgl_homg_point_3d< T > const &  X) const [inline]

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

Definition at line 86 of file vgl_p_matrix.h.

template<class T >
vgl_homg_line_2d< T > vgl_p_matrix< T >::operator() ( vgl_homg_line_3d_2_points< T > const &  L) const

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

Definition at line 92 of file vgl_p_matrix.txx.

template<class T >
vgl_line_segment_2d< T > vgl_p_matrix< T >::operator() ( vgl_line_segment_3d< T > const &  L) const

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

Definition at line 100 of file vgl_p_matrix.txx.

template<class T>
vgl_homg_point_2d<T> vgl_p_matrix< T >::operator* ( vgl_homg_point_3d< T > const &  X) const [inline]

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

Definition at line 88 of file vgl_p_matrix.h.

template<class T>
vgl_homg_line_2d<T> vgl_p_matrix< T >::operator* ( vgl_homg_line_3d_2_points< T > const &  L) const [inline]

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

Definition at line 92 of file vgl_p_matrix.h.

template<class T>
vgl_line_segment_2d<T> vgl_p_matrix< T >::operator* ( vgl_line_segment_3d< T > const &  L) const [inline]

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

Definition at line 96 of file vgl_p_matrix.h.

template<class T>
vgl_p_matrix<T> vgl_p_matrix< T >::operator* ( vnl_matrix_fixed< T, 3, 3 > const &  C) const [inline]

pre-multiply this projection matrix with a 2-d projective transform.

Definition at line 114 of file vgl_p_matrix.h.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::operator= ( const vgl_p_matrix< T > &  that)

Definition at line 70 of file vgl_p_matrix.txx.

template<class T>
bool vgl_p_matrix< T >::operator== ( vgl_p_matrix< T > const &  p) const [inline]

Definition at line 148 of file vgl_p_matrix.h.

template<class T >
vgl_p_matrix< T > vgl_p_matrix< T >::postmultiply ( vnl_matrix_fixed< T, 4, 4 > const &  H) const

post-multiply this projection matrix with a 3-d projective transform.

Definition at line 535 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > vgl_p_matrix< T >::premultiply ( vnl_matrix_fixed< T, 3, 3 > const &  H) const

pre-multiply this projection matrix with a 2-d projective transform.

Definition at line 541 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > vgl_p_matrix< T >::read ( const char *  filename) [static]

Load from file.

Static method, so you can say

Definition at line 165 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > vgl_p_matrix< T >::read ( vcl_istream &  s) [static]

Load from vcl_istream.

Definition at line 181 of file vgl_p_matrix.txx.

template<class T >
bool vgl_p_matrix< T >::read_ascii ( vcl_istream &  f)

Load from file.

 P.read_ascii("file.P");

Definition at line 150 of file vgl_p_matrix.txx.

template<class T>
vgl_p_matrix& vgl_p_matrix< T >::set ( vnl_matrix_fixed< T, 3, 4 > const &  p_matrix) [inline]

Set the internal matrix using the 3x4 p_matrix.

Definition at line 172 of file vgl_p_matrix.h.

template<class T>
vgl_p_matrix& vgl_p_matrix< T >::set ( const vnl_matrix< T > &  p_matrix) [inline]

Deprecated; use the vnl_matrix_fixed variant instead.

Definition at line 174 of file vgl_p_matrix.h.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::set ( vnl_matrix_fixed< T, 3, 3 > const &  A,
vnl_vector_fixed< T, 3 > const &  a 
)

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

Definition at line 422 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::set ( vnl_matrix< T > const &  A,
vnl_vector< T > const &  a 
)

Deprecated; use the vnl_matrix_fixed variant instead.

Definition at line 447 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::set ( const T *  p_matrix)

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

Definition at line 408 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::set ( const T  p_matrix[3][4])

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

Definition at line 395 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::set_identity ( )

Set the camera to an identity projection. X->u, Y->v.

Definition at line 471 of file vgl_p_matrix.txx.

template<class T >
vgl_p_matrix< T > & vgl_p_matrix< T >::set_rows ( const vnl_vector_fixed< T, 4 > &  a,
const vnl_vector_fixed< T, 4 > &  b,
const vnl_vector_fixed< T, 4 > &  c 
)

Set P = [a b c]' from its rows a, b, c.

Definition at line 371 of file vgl_p_matrix.txx.

template<class T >
vnl_svd< T > * vgl_p_matrix< T >::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 193 of file vgl_p_matrix.txx.


Member Data Documentation

template<class T>
vnl_matrix_fixed<T, 3,4> vgl_p_matrix< T >::p_matrix_ [protected]

Definition at line 199 of file vgl_p_matrix.h.

template<class T>
vnl_svd<T>* vgl_p_matrix< T >::svd_ [mutable, protected]

Definition at line 200 of file vgl_p_matrix.h.


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