contrib/oxl/mvl/FMatrixComputeRobust.h
Go to the documentation of this file.
00001 #ifndef FMatrixComputeRobust_h_
00002 #define FMatrixComputeRobust_h_
00003 //:
00004 // \file
00005 // \brief Robust FMatrix computation
00006 //
00007 //  FMatrixComputeRobust is a base class for robust F Matrix calculations.
00008 //  Relevant methods are abstracted to allow for sub-classing
00009 //  of different robust variants.
00010 //
00011 // \author
00012 //     David N. McKinnon, UQ I.R.I.S., 17.05.2001
00013 //
00014 // \verbatim
00015 //  Modifications
00016 //   22 Oct 2002 - Peter Vanroose - added vgl_homg_point_2d interface
00017 // \endverbatim
00018 //
00019 //-----------------------------------------------------------------------------
00020 
00021 #include <mvl/FMatrixCompute.h>
00022 #include <mvl/HomgPoint2D.h>
00023 #include <vgl/vgl_homg_point_2d.h>
00024 #include <vcl_vector.h>
00025 
00026 class FMatrixComputeRobust : public FMatrixCompute
00027 {
00028  public:
00029   FMatrixComputeRobust();
00030   virtual ~FMatrixComputeRobust();
00031 
00032   // FMatrixCompute virtuals---------------------------------------------------
00033 
00034   //: Compute a fundamental matrix for a set of point matches.
00035   // This is the implemented method, other computes wrap this.
00036   bool compute(PairMatchSetCorner& matches, FMatrix* F);
00037   bool compute(vcl_vector<HomgPoint2D>& p1, vcl_vector<HomgPoint2D>& p2, FMatrix* F)
00038     { return FMatrixCompute::compute(p1,p2,F); }
00039   bool compute(vcl_vector<vgl_homg_point_2d<double> >& p1,
00040                vcl_vector<vgl_homg_point_2d<double> >& p2,
00041                FMatrix& F)
00042     { return FMatrixCompute::compute(p1,p2,F); }
00043 
00044   inline FMatrix compute(PairMatchSetCorner& p) { return FMatrixCompute::compute(p); }
00045   inline FMatrix compute(vcl_vector<HomgPoint2D>& p1, vcl_vector<HomgPoint2D>& p2)
00046     { return FMatrixCompute::compute(p1,p2); }
00047   inline FMatrix compute(vcl_vector<vgl_homg_point_2d<double> >& p1,
00048                          vcl_vector<vgl_homg_point_2d<double> >& p2)
00049     { return FMatrixCompute::compute(p1,p2); }
00050 
00051   // Data Access---------------------------------------------------------------
00052 
00053   vcl_vector<int> get_basis() const { return basis_; }
00054   HomgPoint2D get_epipole1() const { return epipole1_; }
00055   HomgPoint2D get_epipole2() const { return epipole2_; }
00056   vcl_vector<double> get_residuals() const { return residuals_; }
00057   vcl_vector<bool> get_inliers() const { return inliers_; }
00058 
00059   // These virtual functions must be implemented
00060   virtual double calculate_term(vcl_vector<double>& residuals, vcl_vector<bool>& inlier_list, int& count);
00061   virtual double calculate_residual(HomgPoint2D& one, HomgPoint2D& two, FMatrix* F);
00062   virtual double calculate_residual(vgl_homg_point_2d<double>& one,
00063                                     vgl_homg_point_2d<double>& two, FMatrix* F);
00064   vcl_vector<double> calculate_residuals(vcl_vector<HomgPoint2D>& one, vcl_vector<HomgPoint2D>& two, FMatrix* F);
00065   vcl_vector<double> calculate_residuals(vcl_vector<vgl_homg_point_2d<double> >& one,
00066                                          vcl_vector<vgl_homg_point_2d<double> >& two,
00067                                          FMatrix* F);
00068   double stdev(vcl_vector<double>& residuals);
00069  protected:
00070   bool rank2_truncate_;
00071   double inthresh_;
00072   double std_;
00073  private:
00074   int row_;
00075   int col_;
00076   vcl_vector<int> basis_;
00077   HomgPoint2D epipole1_;
00078   HomgPoint2D epipole2_;
00079   int data_size_;
00080   vcl_vector<double> residuals_;
00081   vcl_vector<bool> inliers_;
00082 };
00083 
00084 #endif // FMatrixComputeRobust_h_