core/vpgl/vpgl_essential_matrix.h
Go to the documentation of this file.
00001 // This is core/vpgl/vpgl_essential_matrix.h
00002 #ifndef vpgl_essential_matrix_h_
00003 #define vpgl_essential_matrix_h_
00004 //:
00005 // \file
00006 // \brief A class for the essential matrix between two projective cameras.
00007 // \author Joseph Mundy
00008 // \date February 28, 2007
00009 //
00010 //  The essential matrix is related to the fundamental matrix by
00011 //       $E = [K_{left}]^t [F] [K_{right}]$
00012 // The notation "left" and "right" refers to camera producing points used
00013 // on the left side of the F or E matrix and vice versa.
00014 // Note: the extract left camera function requires points be transformed to
00015 // the camera focal plane. That is, e.g.,
00016 // left_coor(in camera focal plane coordinates) =
00017 //    $[K_{left}]^{-1} p_{left}$ (in image coordinates).
00018 #include <vnl/vnl_fwd.h>
00019 #include <vnl/vnl_matrix_fixed.h>
00020 #include <vgl/vgl_fwd.h>
00021 #include <vcl_iosfwd.h>
00022 
00023 #include "vpgl_perspective_camera.h"
00024 #include "vpgl_calibration_matrix.h"
00025 #include "vpgl_fundamental_matrix.h"
00026 
00027 
00028 template <class T>
00029 class vpgl_essential_matrix : public vpgl_fundamental_matrix<T>
00030 {
00031  public:
00032   // Constructors:----------------------
00033 
00034   //: Default constructor creates dummy rank 2 matrix.
00035   vpgl_essential_matrix();
00036 
00037   //: construct from a fundamental matrix and left and right calibration matrices
00038   vpgl_essential_matrix( const vpgl_fundamental_matrix<T>& F,
00039                          const vpgl_calibration_matrix<T>& K_left,
00040                          const vpgl_calibration_matrix<T>& K_right);
00041 
00042 
00043   //: Main constructor takes two perspective cameras.
00044   //  The RHS of the essential matrix will correspond to cr and the LHS to cl.
00045   vpgl_essential_matrix( const vpgl_perspective_camera<T>& cr,
00046                          const vpgl_perspective_camera<T>& cl );
00047 
00048   //: Construct from an essential matrix in vnl form.
00049   vpgl_essential_matrix( const vnl_matrix_fixed<T,3,3>& E ) : vpgl_fundamental_matrix<T>(E) {}
00050 
00051   //: Copy Constructor
00052   vpgl_essential_matrix(const vpgl_essential_matrix<T>& other);
00053 
00054   //: Assignment
00055   const vpgl_essential_matrix<T>& operator=( const vpgl_essential_matrix<T>& em );
00056 
00057   //: Destructor
00058   virtual ~vpgl_essential_matrix();
00059 };
00060 
00061 //Public functions
00062 //: Left camera extractor. Normalized correspondence pair is needed to determine which of four solutions should be used, i.e. focal plane coordinates
00063 // The translation part of the camera is normalized to the indicated magnitude.
00064 template <class T>
00065 bool extract_left_camera(const vpgl_essential_matrix<T>& E,
00066                          const vgl_point_2d<T>& left_corr,//focal plane coordinates
00067                          const vgl_point_2d<T>& right_corr,//focal plane coordinates
00068                          vpgl_perspective_camera<T>& p_left,
00069                          const T translation_mag = (T)1);
00070 
00071 //:vpgl_essential_matrix stream I/O
00072 
00073 template <class T>
00074 vcl_ostream&  operator<<(vcl_ostream& s, vpgl_essential_matrix<T> const& p);
00075 
00076 //: Read vpgl_perspective_camera  from stream
00077 template <class T>
00078 vcl_istream&  operator>>(vcl_istream& s, vpgl_essential_matrix<T>& p);
00079 
00080 #endif // vpgl_essential_matrix_h_