contrib/oxl/mvl/FMatrixComputeNonLinear.h
Go to the documentation of this file.
00001 // This is oxl/mvl/FMatrixComputeNonLinear.h
00002 #ifndef FMatrixComputeNonLinear_h_
00003 #define FMatrixComputeNonLinear_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 //    FMatrixComputeNonLinear is a class that contains the functions required for
00010 //  two differing Non-Linear minimisations of the F Matrix:
00011 //  - Zhengyou Zhang's 36 different rank 2 parametrisations of the F Matrix
00012 //  - Phil Torr's augmentation of a given 7 points basis
00013 //
00014 // \author
00015 //     David McKinnon, U.Q. 2/1/01
00016 //
00017 //-----------------------------------------------------------------------------
00018 
00019 #include <vcl_vector.h>
00020 #include <vnl/vnl_least_squares_function.h>
00021 #include <vgl/vgl_homg_point_2d.h>
00022 #include <mvl/AffineMetric.h>
00023 #include <mvl/HomgNorm2D.h>
00024 #include <mvl/PairMatchSetCorner.h>
00025 #include <mvl/FMatrix.h> // needed since there is an FMatrix data member
00026 
00027 class FMatrixComputeNonLinear : public vnl_least_squares_function
00028 {
00029  public:
00030 
00031   // Constructors/Destructors--------------------------------------------------
00032   FMatrixComputeNonLinear(PairMatchSetCorner* matches);
00033 
00034   // Computations--------------------------------------------------------------
00035   // Calling this function results in the 36 parametrisations
00036   bool compute(FMatrix* F);
00037   // Calling this function results in the augmentation of the basis
00038   bool compute_basis(FMatrix* F, vcl_vector<int> basis);
00039 
00040   // The virtual function from vnl_levenberg_marquardt
00041   void f(const vnl_vector<double>& x, vnl_vector<double>& fx);
00042 
00043  private:
00044   // Data Members--------------------------------------------------------------
00045   int data_size_;
00046   int terminate_count_;
00047   PairMatchSetCorner& matches_;
00048   int p_, q_, r_;
00049   FMatrix F_orig_;
00050   bool one_;
00051   vcl_vector<vgl_homg_point_2d<double> > basis1_;
00052   vcl_vector<vgl_homg_point_2d<double> > basis2_;
00053   vcl_vector<vgl_homg_point_2d<double> > points1_;
00054   vcl_vector<vgl_homg_point_2d<double> > points2_;
00055 
00056   // Helpers-------------------------------------------------------------------
00057   void fmatrix_to_params(const FMatrix& F, vnl_vector<double>& params);
00058   FMatrix params_to_fmatrix(const vnl_vector<double>& params);
00059   void get_plan(int &r1, int &c1, int &r2, int &c2);
00060   vnl_vector<double> calculate_residuals(FMatrix* F);
00061 };
00062 
00063 #endif // FMatrixComputeNonLinear_h_