contrib/oxl/mvl/FMatrixComputeLMedSq.h
Go to the documentation of this file.
00001 #ifndef FMatrixComputeLMedSq_h_
00002 #define FMatrixComputeLMedSq_h_
00003 //:
00004 // \file
00005 // \brief Robust FMatrix computation
00006 //
00007 //    FMatrixComputeLMedSq implements
00008 //    Zhengyou Zhang's LMedSq (Least Medium of Squares Estimation) of the fundamental matrix.
00009 //
00010 //    Points are preconditioned as described in [Hartley, ``In defense of
00011 //    the 8-point algorithm'', ICCV95], and the resulting F matrix is rank-2
00012 //    truncated.  The conditioning and truncation are optional and may be
00013 //    omitted.
00014 //
00015 // \author
00016 //     David N. McKinnon, UQ I.R.I.S., 02.12.2000
00017 //
00018 // \verbatim
00019 // Modifications
00020 //    22 Oct 2002 - Peter Vanroose - added vgl_homg_point_2d interface
00021 // \endverbatim
00022 //
00023 //-----------------------------------------------------------------------------
00024 
00025 #include <vgl/vgl_fwd.h>
00026 #include <mvl/FMatrixComputeRobust.h>
00027 #include <vcl_vector.h>
00028 
00029 class FMatrixComputeLMedSq : public FMatrixComputeRobust
00030 {
00031  public:
00032   //: Initialize FMatrixComputeRobust object.
00033   // If rank2_truncate = false, the resulting solution is not forced to rank 2
00034   // using the vnl_svd<double>.
00035   FMatrixComputeLMedSq(bool rank2_truncate, int size);
00036   virtual ~FMatrixComputeLMedSq();
00037 
00038   virtual double calculate_term(vcl_vector<double>& residuals, vcl_vector<bool>& inlier_list, int& count);
00039   virtual double calculate_residual(HomgPoint2D& one, HomgPoint2D& two, FMatrix* F);
00040   virtual double calculate_residual(vgl_homg_point_2d<double>& one,
00041                                     vgl_homg_point_2d<double>& two, FMatrix* F);
00042  private:
00043   // Helper Functions
00044   // Return the median value for a vector of residuals
00045   double median(vcl_vector<double> residuals);
00046 };
00047 
00048 #endif // FMatrixComputeLMedSq_h_