core/vpgl/algo/vpgl_fm_compute_7_point.h
Go to the documentation of this file.
00001 // This is core/vpgl/algo/vpgl_fm_compute_7_point.h
00002 #ifndef vpgl_fm_compute_7_point_h_
00003 #define vpgl_fm_compute_7_point_h_
00004 //:
00005 // \file
00006 // \brief The 7 point algorithm for computing a fundamental matrix from point correspondences.
00007 // \author Thomas Pollard
00008 // \date May 10, 2005
00009 //
00010 // Should template this class. The code here is lifted from oxl/mvl/FMatrixCompute7Point.
00011 // Still need to add preconditioning to points.
00012 
00013 #include <vgl/vgl_homg_point_2d.h>
00014 #include <vpgl/vpgl_fundamental_matrix.h>
00015 
00016 class vpgl_fm_compute_7_point
00017 {
00018  public:
00019   //: If precondition = true, points are conditioned prior to computation.
00020   vpgl_fm_compute_7_point( bool precondition = true )
00021    : precondition_(precondition) {}
00022 
00023   //: Compute from two sets of corresponding points.
00024   // Put the resulting matrix into fm, return true if successful.
00025   // Points pr are associated with the RHS of the fundamental matrix
00026   // while the points pl are associated with the LHS.
00027   bool compute( const vcl_vector< vgl_homg_point_2d<double> >& pr,
00028                 const vcl_vector< vgl_homg_point_2d<double> >& pl,
00029                 vcl_vector< vpgl_fundamental_matrix<double>* >& fm );
00030 
00031  protected:
00032   static vcl_vector<double> get_coeffs( vnl_double_3x3 const& F1,
00033                                         vnl_double_3x3 const& F2 );
00034   static vcl_vector<double> solve_quadratic( vcl_vector<double> v );
00035   static vcl_vector<double> solve_cubic( vcl_vector<double> v );
00036   bool precondition_;
00037 };
00038 
00039 #endif // vpgl_fm_compute_7_point_h_