contrib/oxl/mvl/FMatrixComputeLinear.h
Go to the documentation of this file.
00001 // This is oxl/mvl/FMatrixComputeLinear.h
00002 #ifndef FMatrixComputeLinear_h_
00003 #define FMatrixComputeLinear_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Hartley 8-point fundamental matrix fit
00010 //
00011 //    FMatrixComputeLinear is a subclass of FMatrixCompute, and implements
00012 //    the ``8-point'' or linear least squares algorithm for estimation of
00013 //    the fundamental matrix.
00014 //
00015 //    Points are preconditioned as described in [Hartley, ``In defense of
00016 //    the 8-point algorithm'', ICCV95], and the resulting F matrix is rank-2
00017 //    truncated.  The conditioning and truncation are optional and may be
00018 //    omitted.
00019 //
00020 //    Note: As with any nonrobust algorithm, mismatches in the input data
00021 //    may severely effect the result.
00022 //
00023 // \example examples/exampleFMatrixCompute.cxx
00024 //
00025 // \author
00026 //     Andrew W. Fitzgibbon, Oxford RRG, 21 Aug 96
00027 //
00028 // \verbatim
00029 // Modifications
00030 //    22 Oct 2002 - Peter Vanroose - added vgl_homg_point_2d interface
00031 // \endverbatim
00032 //
00033 //-----------------------------------------------------------------------------
00034 
00035 #include <vgl/vgl_fwd.h>
00036 #include <mvl/FMatrixCompute.h>
00037 #include <mvl/FMatrix.h>
00038 
00039 class FMatrixComputeLinear : public FMatrixCompute
00040 {
00041   bool precondition_;
00042   bool rank2_truncate_;
00043  public:
00044   //: Initialize FMatrixComputeLinear object.
00045   //  If precondition = false, points are not conditioned prior to computation.
00046   // If rank2_truncate = false, the resulting solution is not forced to rank 2
00047   // using the vnl_svd<double>.
00048   FMatrixComputeLinear(bool precondition = true, bool rank2_truncate = true);
00049 
00050   // Computations--------------------------------------------------------------
00051 
00052   //: Compute a fundamental matrix for a set of point matches.
00053   //
00054   // Return false if the calculation fails or there are fewer than eight point
00055   // matches in the list.
00056   //
00057   bool compute(PairMatchSetCorner&, FMatrix* F);
00058 
00059   //: Interface to above using arrays of HomgPoint2D.
00060   //  Makes a PairMatchSetCorner, and then calls the compute method above.
00061   bool compute(vcl_vector<HomgPoint2D>&, vcl_vector<HomgPoint2D>&, FMatrix* F);
00062 
00063   //: Interface to above using arrays of vgl_homg_point_2d.
00064   //  Makes a PairMatchSetCorner, and then calls the compute method above.
00065   bool compute(vcl_vector<vgl_homg_point_2d<double> >&,
00066                vcl_vector<vgl_homg_point_2d<double> >&,
00067                FMatrix& F);
00068 
00069   //: Interface to above using preconditioned points
00070   bool compute_preconditioned(vcl_vector<HomgPoint2D>&, vcl_vector<HomgPoint2D>&, FMatrix* F);
00071 
00072   //: Interface to above using preconditioned points
00073   bool compute_preconditioned(vcl_vector<vgl_homg_point_2d<double> >&,
00074                               vcl_vector<vgl_homg_point_2d<double> >&,
00075                               FMatrix& F);
00076 
00077   inline FMatrix compute(PairMatchSetCorner& p) { return FMatrixCompute::compute(p); }
00078   inline FMatrix compute(vcl_vector<HomgPoint2D>& p1, vcl_vector<HomgPoint2D>& p2)
00079   { return FMatrixCompute::compute(p1,p2); }
00080   inline FMatrix compute(vcl_vector<vgl_homg_point_2d<double> >& p1,
00081                          vcl_vector<vgl_homg_point_2d<double> >& p2)
00082   { return FMatrixCompute::compute(p1,p2); }
00083 };
00084 
00085 #endif // FMatrixComputeLinear_h_