Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
vgl_p_matrix< T > Class Template Reference

#include <vgl_algo_fwd.h>

Public Member Functions

 vgl_p_matrix ()
 Constructor. Set up a canonical P matrix. More...
 
 vgl_p_matrix (std::istream &)
 Construct by loading from std::istream. More...
 
 vgl_p_matrix (const T *c_matrix)
 Construct from row-stored C-array of 12 elements. More...
 
 vgl_p_matrix (vnl_matrix_fixed< T, 3, 4 > const &P)
 Construct from 3x4 matrix. More...
 
 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]. More...
 
 vgl_p_matrix (const vnl_matrix< T > &A, const vnl_vector< T > &a)
 Deprecated; use the vnl_matrix_fixed variant instead. More...
 
 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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
vgl_homg_point_3d< T > backproject_pseudoinverse (vgl_homg_point_2d< T > const &x) const
 Return the 3D point $\vec X$ which is $\vec X = P^+ \vec x$. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void clear_svd () const
 Discredit the cached svd. More...
 
vgl_homg_point_3d< T > get_focal () const
 Return the 3D point representing the focal point of the camera. More...
 
vgl_h_matrix_3d< T > get_canonical_H () const
 Return the 3D H-matrix s.t. P * H = [I 0]. More...
 
bool is_canonical (T tol=0) const
 Return true iff P is [I 0]. More...
 
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. More...
 
vgl_p_matrixflip_sign ()
 Change the overall sign of the P matrix. More...
 
bool looks_conditioned ()
 Splendid hack that tries to detect if the P is an image-coords P or a normalized P. More...
 
vgl_p_matrixfix_cheirality ()
 Scale P so determinant of first 3x3 is 1. More...
 
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]. More...
 
void get (vnl_matrix< T > *A, vnl_vector< T > *a) const
 Deprecated; use the vnl_matrix_fixed variant instead. More...
 
void get_rows (vnl_vector< T > *a, vnl_vector< T > *b, vnl_vector< T > *c) const
 Return the rows of P = [a b c]'. More...
 
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]'. More...
 
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. More...
 
get (unsigned int row_index, unsigned int col_index) const
 Return the element of the matrix at the specified index pair. More...
 
void get (T *c_matrix) const
 Return the 3x4 projection matrix in the C-array, c_matrix. More...
 
void get (vnl_matrix_fixed< T, 3, 4 > &p_matrix) const
 Return the 3x4 projection matrix in p_matrix. More...
 
void get (vnl_matrix< T > &p_matrix) const
 Deprecated; use the vnl_matrix_fixed variant instead. More...
 
vgl_p_matrixset (vnl_matrix_fixed< T, 3, 4 > const &p_matrix)
 Set the internal matrix using the 3x4 p_matrix. More...
 
vgl_p_matrixset (const vnl_matrix< T > &p_matrix)
 Deprecated; use the vnl_matrix_fixed variant instead. More...
 
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]. More...
 
vgl_p_matrixset (vnl_matrix< T > const &A, vnl_vector< T > const &a)
 Deprecated; use the vnl_matrix_fixed variant instead. More...
 
vgl_p_matrixset (const T *p_matrix)
 Set the projective matrix with the matrix in the 3x4 C-array, p_matrix. More...
 
vgl_p_matrixset (const T p_matrix [3][4])
 Set the projective matrix with the matrix in the 3x4 C-array, p_matrix. More...
 
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. More...
 
bool read_ascii (std::istream &f)
 Load from file. More...
 

Static Public Member Functions

static vgl_p_matrix read (const char *filename)
 Load from file. More...
 
static vgl_p_matrix read (std::istream &)
 Load from std::istream. More...
 

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 13 of file vgl_algo_fwd.h.

Constructor & Destructor Documentation

◆ vgl_p_matrix() [1/7]

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

Constructor. Set up a canonical P matrix.

Definition at line 26 of file vgl_p_matrix.hxx.

◆ vgl_p_matrix() [2/7]

template<class T >
vgl_p_matrix< T >::vgl_p_matrix ( std::istream &  i)

Construct by loading from std::istream.

vgl_p_matrix P(cin);

Definition at line 40 of file vgl_p_matrix.hxx.

◆ vgl_p_matrix() [3/7]

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 57 of file vgl_p_matrix.hxx.

◆ vgl_p_matrix() [4/7]

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 49 of file vgl_p_matrix.hxx.

◆ vgl_p_matrix() [5/7]

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.

◆ vgl_p_matrix() [6/7]

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.

◆ vgl_p_matrix() [7/7]

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

Definition at line 66 of file vgl_p_matrix.hxx.

◆ ~vgl_p_matrix()

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

Definition at line 84 of file vgl_p_matrix.hxx.

Member Function Documentation

◆ backproject() [1/2]

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 122 of file vgl_p_matrix.hxx.

◆ backproject() [2/2]

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 130 of file vgl_p_matrix.hxx.

◆ backproject_pseudoinverse()

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 $\vec X$ which is $\vec X = P^+ \vec x$.

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

Definition at line 113 of file vgl_p_matrix.hxx.

◆ clear_svd()

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 205 of file vgl_p_matrix.hxx.

◆ fix_cheirality()

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 482 of file vgl_p_matrix.hxx.

◆ flip_sign()

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

Change the overall sign of the P matrix.

Definition at line 519 of file vgl_p_matrix.hxx.

◆ get() [1/6]

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 302 of file vgl_p_matrix.hxx.

◆ get() [2/6]

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 279 of file vgl_p_matrix.hxx.

◆ get() [3/6]

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 260 of file vgl_p_matrix.hxx.

◆ get() [4/6]

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 268 of file vgl_p_matrix.hxx.

◆ get() [5/6]

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.

◆ get() [6/6]

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.

◆ get_canonical_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 228 of file vgl_p_matrix.hxx.

◆ get_focal()

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 213 of file vgl_p_matrix.hxx.

◆ get_matrix()

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.

◆ get_rows() [1/2]

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 325 of file vgl_p_matrix.hxx.

◆ get_rows() [2/2]

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 350 of file vgl_p_matrix.hxx.

◆ is_behind_camera()

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 508 of file vgl_p_matrix.hxx.

◆ is_canonical()

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 237 of file vgl_p_matrix.hxx.

◆ looks_conditioned()

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 528 of file vgl_p_matrix.hxx.

◆ operator *() [1/4]

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.

◆ operator *() [2/4]

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.

◆ operator *() [3/4]

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.

◆ operator *() [4/4]

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.

◆ operator()() [1/3]

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.

◆ operator()() [2/3]

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 95 of file vgl_p_matrix.hxx.

◆ operator()() [3/3]

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 103 of file vgl_p_matrix.hxx.

◆ operator=()

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

Definition at line 73 of file vgl_p_matrix.hxx.

◆ operator==()

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.

◆ postmultiply()

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 538 of file vgl_p_matrix.hxx.

◆ premultiply()

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 544 of file vgl_p_matrix.hxx.

◆ read() [1/2]

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 168 of file vgl_p_matrix.hxx.

◆ read() [2/2]

template<class T >
vgl_p_matrix< T > vgl_p_matrix< T >::read ( std::istream &  s)
static

Load from std::istream.

Definition at line 184 of file vgl_p_matrix.hxx.

◆ read_ascii()

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

Load from file.

P.read_ascii("file.P");

Definition at line 153 of file vgl_p_matrix.hxx.

◆ set() [1/6]

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.

◆ set() [2/6]

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.

◆ set() [3/6]

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 425 of file vgl_p_matrix.hxx.

◆ set() [4/6]

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 450 of file vgl_p_matrix.hxx.

◆ set() [5/6]

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 411 of file vgl_p_matrix.hxx.

◆ set() [6/6]

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 398 of file vgl_p_matrix.hxx.

◆ set_identity()

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 474 of file vgl_p_matrix.hxx.

◆ set_rows()

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 374 of file vgl_p_matrix.hxx.

◆ svd()

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 196 of file vgl_p_matrix.hxx.

Member Data Documentation

◆ p_matrix_

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.

◆ svd_

template<class T>
vnl_svd<T>* vgl_p_matrix< T >::svd_
mutableprotected

Definition at line 200 of file vgl_p_matrix.h.


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