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

This class implements the perspective camera class as described in Hartley & Zisserman as a finite camera. More...

#include <vpgl_perspective_camera.h>

Inheritance diagram for vpgl_perspective_camera< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 vpgl_perspective_camera ()
 Default constructor.
 vpgl_perspective_camera (const vpgl_calibration_matrix< T > &K, const vgl_point_3d< T > &camera_center, const vgl_rotation_3d< T > &R)
 Main constructor takes all of the camera parameters.
 vpgl_perspective_camera (const vpgl_calibration_matrix< T > &K, const vgl_rotation_3d< T > &R, const vgl_vector_3d< T > &t)
 Main constructor based on K[R|t].
 vpgl_perspective_camera (const vpgl_perspective_camera &cam)
 Copy constructor.
virtual ~vpgl_perspective_camera ()
 Destructor.
virtual vcl_string type_name () const
 class identity functions for casting.
virtual vpgl_proj_camera< T > * clone (void) const
 Clone `this': creation of a new object and initialization.
vgl_homg_line_3d_2_points< T > backproject (const vgl_homg_point_2d< T > &image_point) const
 Finite backprojection.
vgl_line_3d_2_points< T > backproject (const vgl_point_2d< T > &image_point) const
 Finite backprojection.
vgl_line_3d_2_points< T > backproject (T u, T v) const
 Finite backprojection.
vgl_ray_3d< T > backproject_ray (const vgl_point_2d< T > &image_point) const
 Finite ray backprojection.
vgl_ray_3d< T > backproject_ray (T u, T v) const
 Finite ray backprojection at u v.
vgl_vector_3d< T > principal_axis () const
 Compute the principal axis.
bool is_behind_camera (const vgl_homg_point_3d< T > &world_point) const
 Determine whether the given point lies in front of the principal plane.
void set_calibration (const vpgl_calibration_matrix< T > &K)
 Setters and getters.
void set_camera_center (const vgl_point_3d< T > &camera_center)
void set_translation (const vgl_vector_3d< T > &t)
void set_rotation (const vgl_rotation_3d< T > &R)
const vpgl_calibration_matrix
< T > & 
get_calibration () const
const vgl_point_3d< T > & get_camera_center () const
vgl_vector_3d< T > get_translation () const
const vgl_rotation_3d< T > & get_rotation () const
void look_at (const vgl_homg_point_3d< T > &point, const vgl_vector_3d< T > &up=vgl_vector_3d< T >(0, 0, 1))
 Rotate the camera about its center such that it looks at the given point.
virtual vgl_homg_point_3d< T > camera_center () const
 Return the known camera center instead of computing it in the base class.
bool operator== (vpgl_perspective_camera< T > const &that) const
 Equality test.
virtual void save (vcl_string cam_path)
 Save in ascii format.
virtual
vpgl_perspective_camera< T > * 
cast_to_perspective_camera ()
 Return `this' if `this' is a vpgl_perspective_camera, 0 otherwise.
virtual const
vpgl_perspective_camera< T > * 
cast_to_perspective_camera () const
bool operator== (vpgl_proj_camera< T > const &that) const
 Equality test.
virtual void project (const T x, const T y, const T z, T &u, T &v) const
 Projection from base class.
virtual vgl_homg_point_2d< T > project (const vgl_homg_point_3d< T > &world_point) const
 Project a point in world coordinates onto the image plane.
vgl_homg_point_2d< T > project (const vgl_point_3d< T > &world_point) const
 Non-homogeneous version of the above.
vgl_line_segment_2d< T > project (const vgl_line_segment_3d< T > &world_line) const
 Project a line in the world onto a line in the image plane.
vgl_line_2d< T > project (const vgl_infinite_line_3d< T > &world_line) const
 Project an infinite line in the world onto an infinite line in the image plane.
vgl_homg_point_2d< T > operator() (const vgl_homg_point_3d< T > &world_point) const
 A shortcut to the above function.
vgl_line_segment_2d< T > operator() (const vgl_line_segment_3d< T > &world_line) const
 Standard () forward projection operator.
vgl_line_2d< T > operator() (const vgl_infinite_line_3d< T > &world_line) const
 Standard () forward projection operator.
virtual vgl_ray_3d< T > backproject_ray (const vgl_homg_point_2d< T > &image_point) const
 Find the 3d ray that goes through the camera center and the provided image point.
vgl_homg_plane_3d< T > backproject (const vgl_homg_line_2d< T > &image_line) const
 Find the 3d plane that contains the camera center and the provided line in the image plane.
virtual vgl_homg_plane_3d< T > principal_plane () const
 Find the world plane parallel to the image plane intersecting the camera center.
vgl_homg_point_2d< T > x_vanishing_point () const
 Find the image coordinates of the vanishing points of the world coordinate axes.
vgl_homg_point_2d< T > y_vanishing_point () const
vgl_homg_point_2d< T > z_vanishing_point () const
const vnl_matrix_fixed< T, 3, 4 > & get_matrix () const
 Return a copy of the camera matrix.
vnl_svd< T > * svd () const
 Get a copy of the svd of the get_matrix.
virtual bool set_matrix (const vnl_matrix_fixed< T, 3, 4 > &new_camera_matrix)
 Setters mirror the constructors and return true if the setting was successful.
virtual bool set_matrix (const T *new_camera_matrix)
vcl_string is_a () const
bool is_class (vcl_string const &name) const
void ref ()
void unref ()
int get_references () const
bool is_referenced () const

Static Public Member Functions

static vpgl_perspective_camera< T > postmultiply (const vpgl_perspective_camera< T > &in_cam, const vgl_h_matrix_3d< T > &euclid_trans)
 Post-multiply this perspective camera with a 3-d Euclidean transformation.
static vpgl_perspective_camera< T > postmultiply (const vpgl_perspective_camera< T > &camera, const vgl_rotation_3d< T > &rot, const vgl_vector_3d< T > &trans)
 Apply a 3-d Euclidean transformation (transform external cam parameters).

Protected Member Functions

void recompute_matrix ()
 Recalculate the 3x4 camera matrix from the parameters.

Protected Attributes

vpgl_calibration_matrix< T > K_
vgl_point_3d< T > camera_center_
vgl_rotation_3d< T > R_

Detailed Description

template<class T>
class vpgl_perspective_camera< T >

This class implements the perspective camera class as described in Hartley & Zisserman as a finite camera.

This is the camera model based on three objects: the camera calibration matrix (see "vpgl_calibration_matrix.h"), the camera center, and the rotation of the camera from its canonical orientation staring down the positive z axis.

All rotation matrices entered will be checked that they are indeed rotations, i.e. that R.transpose()*R = Identity and in the form:

     [ R 0 ]
     [ 0 1 ]
    
    Modifications
     Feb 12, 2007  Thomas Pollard   Added finite backprojection method.
   

For adding to this class:

Be sure to call recompute_matrix in your member functions any time you change any of the camera parameters.

Definition at line 55 of file vpgl_perspective_camera.h.


Constructor & Destructor Documentation

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

Default constructor.

Makes a camera at the origin with no rotation and default calibration matrix.

Definition at line 34 of file vpgl_perspective_camera.txx.

template<class T >
vpgl_perspective_camera< T >::vpgl_perspective_camera ( const vpgl_calibration_matrix< T > &  K,
const vgl_point_3d< T > &  camera_center,
const vgl_rotation_3d< T > &  R 
)

Main constructor takes all of the camera parameters.

Definition at line 44 of file vpgl_perspective_camera.txx.

template<class T >
vpgl_perspective_camera< T >::vpgl_perspective_camera ( const vpgl_calibration_matrix< T > &  K,
const vgl_rotation_3d< T > &  R,
const vgl_vector_3d< T > &  t 
)

Main constructor based on K[R|t].

Definition at line 55 of file vpgl_perspective_camera.txx.

template<class T >
vpgl_perspective_camera< T >::vpgl_perspective_camera ( const vpgl_perspective_camera< T > &  cam)

Copy constructor.

Definition at line 67 of file vpgl_perspective_camera.txx.

template<class T>
virtual vpgl_perspective_camera< T >::~vpgl_perspective_camera ( ) [inline, virtual]

Destructor.

Definition at line 77 of file vpgl_perspective_camera.h.


Member Function Documentation

template<class T >
vgl_homg_line_3d_2_points< T > vpgl_perspective_camera< T >::backproject ( const vgl_homg_point_2d< T > &  image_point) const [virtual]

Finite backprojection.

This is a virtual function from the parent class vpgl_proj_camera<T>

Reimplemented from vpgl_proj_camera< T >.

Definition at line 84 of file vpgl_perspective_camera.txx.

template<class T >
vgl_line_3d_2_points< T > vpgl_perspective_camera< T >::backproject ( const vgl_point_2d< T > &  image_point) const

Finite backprojection.

Definition at line 97 of file vpgl_perspective_camera.txx.

template<class T>
vgl_line_3d_2_points<T> vpgl_perspective_camera< T >::backproject ( u,
v 
) const [inline]

Finite backprojection.

Definition at line 91 of file vpgl_perspective_camera.h.

template<class T >
vgl_homg_plane_3d< T > vpgl_proj_camera< T >::backproject ( const vgl_homg_line_2d< T > &  image_line) const [inherited]

Find the 3d plane that contains the camera center and the provided line in the image plane.

Definition at line 175 of file vpgl_proj_camera.txx.

template<class T >
vgl_ray_3d< T > vpgl_perspective_camera< T >::backproject_ray ( const vgl_point_2d< T > &  image_point) const

Finite ray backprojection.

Definition at line 119 of file vpgl_perspective_camera.txx.

template<class T>
vgl_ray_3d<T> vpgl_perspective_camera< T >::backproject_ray ( u,
v 
) const [inline]

Finite ray backprojection at u v.

Definition at line 98 of file vpgl_perspective_camera.h.

template<class T >
vgl_ray_3d< T > vpgl_proj_camera< T >::backproject_ray ( const vgl_homg_point_2d< T > &  image_point) const [virtual, inherited]

Find the 3d ray that goes through the camera center and the provided image point.

Definition at line 159 of file vpgl_proj_camera.txx.

template<class T>
virtual vgl_homg_point_3d<T> vpgl_perspective_camera< T >::camera_center ( ) const [inline, virtual]

Return the known camera center instead of computing it in the base class.

Reimplemented from vpgl_proj_camera< T >.

Definition at line 127 of file vpgl_perspective_camera.h.

template<class T>
virtual vpgl_perspective_camera<T>* vpgl_perspective_camera< T >::cast_to_perspective_camera ( ) [inline, virtual]

Return `this' if `this' is a vpgl_perspective_camera, 0 otherwise.

This is used by e.g. the storage class

Todo:
code for affine camera and other children

Definition at line 158 of file vpgl_perspective_camera.h.

template<class T>
virtual const vpgl_perspective_camera<T>* vpgl_perspective_camera< T >::cast_to_perspective_camera ( ) const [inline, virtual]

Definition at line 159 of file vpgl_perspective_camera.h.

template<class T >
vpgl_proj_camera< T > * vpgl_perspective_camera< T >::clone ( void  ) const [virtual]

Clone `this': creation of a new object and initialization.

See Prototype pattern

Reimplemented from vpgl_proj_camera< T >.

Definition at line 77 of file vpgl_perspective_camera.txx.

template<class T>
const vpgl_calibration_matrix<T>& vpgl_perspective_camera< T >::get_calibration ( ) const [inline]

Definition at line 113 of file vpgl_perspective_camera.h.

template<class T>
const vgl_point_3d<T>& vpgl_perspective_camera< T >::get_camera_center ( ) const [inline]

Definition at line 114 of file vpgl_perspective_camera.h.

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

Return a copy of the camera matrix.

Definition at line 153 of file vpgl_proj_camera.h.

template<class T>
const vgl_rotation_3d<T>& vpgl_perspective_camera< T >::get_rotation ( ) const [inline]

Definition at line 116 of file vpgl_perspective_camera.h.

template<class T >
vgl_vector_3d< T > vpgl_perspective_camera< T >::get_translation ( ) const

Definition at line 185 of file vpgl_perspective_camera.txx.

template<class T>
vcl_string vpgl_camera< T >::is_a ( ) const [inline, inherited]

Reimplemented in vpgl_geo_camera.

Definition at line 37 of file vpgl_camera.h.

template<class T >
bool vpgl_perspective_camera< T >::is_behind_camera ( const vgl_homg_point_3d< T > &  world_point) const

Determine whether the given point lies in front of the principal plane.

Definition at line 138 of file vpgl_perspective_camera.txx.

template<class T>
bool vpgl_camera< T >::is_class ( vcl_string const &  name) const [inline, inherited]

Reimplemented in vpgl_geo_camera.

Definition at line 38 of file vpgl_camera.h.

template<class T >
void vpgl_perspective_camera< T >::look_at ( const vgl_homg_point_3d< T > &  point,
const vgl_vector_3d< T > &  up = vgl_vector_3d<T>(0,0,1) 
)

Rotate the camera about its center such that it looks at the given point.

The camera should also be rotated about its principal axis such that the vertical image direction is closest to up in the world

Definition at line 196 of file vpgl_perspective_camera.txx.

template<class T>
vgl_homg_point_2d<T> vpgl_proj_camera< T >::operator() ( const vgl_homg_point_3d< T > &  world_point) const [inline, inherited]

A shortcut to the above function.

Definition at line 111 of file vpgl_proj_camera.h.

template<class T>
vgl_line_segment_2d<T> vpgl_proj_camera< T >::operator() ( const vgl_line_segment_3d< T > &  world_line) const [inline, inherited]

Standard () forward projection operator.

Definition at line 118 of file vpgl_proj_camera.h.

template<class T>
vgl_line_2d<T> vpgl_proj_camera< T >::operator() ( const vgl_infinite_line_3d< T > &  world_line) const [inline, inherited]

Standard () forward projection operator.

Definition at line 125 of file vpgl_proj_camera.h.

template<class T>
bool vpgl_proj_camera< T >::operator== ( vpgl_proj_camera< T > const &  that) const [inline, inherited]

Equality test.

Definition at line 95 of file vpgl_proj_camera.h.

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

Equality test.

Definition at line 144 of file vpgl_perspective_camera.h.

template<class T >
vpgl_perspective_camera< T > vpgl_perspective_camera< T >::postmultiply ( const vpgl_perspective_camera< T > &  in_cam,
const vgl_h_matrix_3d< T > &  euclid_trans 
) [static]

Post-multiply this perspective camera with a 3-d Euclidean transformation.

Todo:
decide whether this needs to be either a static method or a stand-alone function. (Now both are present.)

Definition at line 382 of file vpgl_perspective_camera.txx.

template<class T >
vpgl_perspective_camera< T > vpgl_perspective_camera< T >::postmultiply ( const vpgl_perspective_camera< T > &  camera,
const vgl_rotation_3d< T > &  rot,
const vgl_vector_3d< T > &  trans 
) [static]

Apply a 3-d Euclidean transformation (transform external cam parameters).

Definition at line 409 of file vpgl_perspective_camera.txx.

template<class T >
vgl_vector_3d< T > vpgl_perspective_camera< T >::principal_axis ( ) const

Compute the principal axis.

i.e. the vector perpendicular to the image plane pointing towards the front of the camera.

Definition at line 127 of file vpgl_perspective_camera.txx.

template<class T>
virtual vgl_homg_plane_3d<T> vpgl_proj_camera< T >::principal_plane ( ) const [inline, virtual, inherited]

Find the world plane parallel to the image plane intersecting the camera center.

Reimplemented in vpgl_affine_camera< T >.

Definition at line 143 of file vpgl_proj_camera.h.

template<class T >
void vpgl_proj_camera< T >::project ( const T  x,
const T  y,
const T  z,
T &  u,
T &  v 
) const [virtual, inherited]

Projection from base class.

Implements vpgl_camera< T >.

Definition at line 101 of file vpgl_proj_camera.txx.

template<class T >
vgl_homg_point_2d< T > vpgl_proj_camera< T >::project ( const vgl_homg_point_3d< T > &  world_point) const [virtual, inherited]

Project a point in world coordinates onto the image plane.

Definition at line 82 of file vpgl_proj_camera.txx.

template<class T>
vgl_homg_point_2d<T> vpgl_proj_camera< T >::project ( const vgl_point_3d< T > &  world_point) const [inline, inherited]

Non-homogeneous version of the above.

Definition at line 107 of file vpgl_proj_camera.h.

template<class T >
vgl_line_segment_2d< T > vpgl_proj_camera< T >::project ( const vgl_line_segment_3d< T > &  world_line) const [inherited]

Project a line in the world onto a line in the image plane.

Definition at line 118 of file vpgl_proj_camera.txx.

template<class T >
vgl_line_2d< T > vpgl_proj_camera< T >::project ( const vgl_infinite_line_3d< T > &  world_line) const [inherited]

Project an infinite line in the world onto an infinite line in the image plane.

Definition at line 131 of file vpgl_proj_camera.txx.

template<class T >
void vpgl_perspective_camera< T >::recompute_matrix ( ) [protected]

Recalculate the 3x4 camera matrix from the parameters.

Definition at line 249 of file vpgl_perspective_camera.txx.

template<class Type >
void vpgl_perspective_camera< Type >::save ( vcl_string  cam_path) [virtual]

Save in ascii format.

Reimplemented from vpgl_proj_camera< T >.

Definition at line 457 of file vpgl_perspective_camera.txx.

template<class T >
void vpgl_perspective_camera< T >::set_calibration ( const vpgl_calibration_matrix< T > &  K)

Setters and getters.

Definition at line 150 of file vpgl_perspective_camera.txx.

template<class T >
void vpgl_perspective_camera< T >::set_camera_center ( const vgl_point_3d< T > &  camera_center)

Definition at line 158 of file vpgl_perspective_camera.txx.

template<class T >
bool vpgl_proj_camera< T >::set_matrix ( const vnl_matrix_fixed< T, 3, 4 > &  new_camera_matrix) [virtual, inherited]

Setters mirror the constructors and return true if the setting was successful.

In subclasses these should be redefined so that they won't allow setting of matrices with improper form.

Definition at line 217 of file vpgl_proj_camera.txx.

template<class T >
bool vpgl_proj_camera< T >::set_matrix ( const T *  new_camera_matrix) [virtual, inherited]

Definition at line 227 of file vpgl_proj_camera.txx.

template<class T >
void vpgl_perspective_camera< T >::set_rotation ( const vgl_rotation_3d< T > &  R)

Definition at line 177 of file vpgl_perspective_camera.txx.

template<class T >
void vpgl_perspective_camera< T >::set_translation ( const vgl_vector_3d< T > &  t)

Definition at line 167 of file vpgl_perspective_camera.txx.

template<class T >
vnl_svd< T > * vpgl_proj_camera< T >::svd ( ) const [inherited]

Get a copy of the svd of the get_matrix.

The svd is cached when first computed and automatically recomputed when the matrix is changed.

Definition at line 200 of file vpgl_proj_camera.txx.

template<class T>
virtual vcl_string vpgl_perspective_camera< T >::type_name ( ) const [inline, virtual]

class identity functions for casting.

Reimplemented from vpgl_proj_camera< T >.

Definition at line 79 of file vpgl_perspective_camera.h.

template<class T>
vgl_homg_point_2d<T> vpgl_proj_camera< T >::x_vanishing_point ( ) const [inline, inherited]

Find the image coordinates of the vanishing points of the world coordinate axes.

Definition at line 146 of file vpgl_proj_camera.h.

template<class T>
vgl_homg_point_2d<T> vpgl_proj_camera< T >::y_vanishing_point ( ) const [inline, inherited]

Definition at line 147 of file vpgl_proj_camera.h.

template<class T>
vgl_homg_point_2d<T> vpgl_proj_camera< T >::z_vanishing_point ( ) const [inline, inherited]

Definition at line 148 of file vpgl_proj_camera.h.


Member Data Documentation

template<class T>
vgl_point_3d<T> vpgl_perspective_camera< T >::camera_center_ [protected]

Definition at line 166 of file vpgl_perspective_camera.h.

template<class T>
vpgl_calibration_matrix<T> vpgl_perspective_camera< T >::K_ [protected]

Definition at line 165 of file vpgl_perspective_camera.h.

template<class T>
vgl_rotation_3d<T> vpgl_perspective_camera< T >::R_ [protected]

Definition at line 167 of file vpgl_perspective_camera.h.


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