00001 // This is oxl/mvl/HMatrix2DAffineCompute.h 00002 #ifndef HMatrix2DAffineCompute_h_ 00003 #define HMatrix2DAffineCompute_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // 00010 // HMatrix2DAffineCompute contains a linear method to compute 00011 // a 2D affine transformation. The H returned is such that 00012 // \f\[ x_2 \sim H x_1 \f\] 00013 // 00014 // \author David Capel, Oxford RRG, 13 May 98 00015 // \verbatim 00016 // Modifications: 00017 // FSM 23-08-98 Added constructor so that the class can be used 00018 // as a compute object. Removed compute() method 00019 // taking PairMatchSet argument. Changed the remaining 00020 // compute method to take an HMatrix2D* argument instead 00021 // of returning an HMatrix2D. 00022 // 22 Oct 2002 - Peter Vanroose - added vgl_homg_point_2d interface 00023 // \endverbatim 00024 00025 #include <mvl/HMatrix2DCompute.h> 00026 #include <mvl/HMatrix2D.h> 00027 #include <vgl/vgl_homg_point_2d.h> 00028 class HomgPoint2D; 00029 00030 class HMatrix2DAffineCompute : public HMatrix2DCompute 00031 { 00032 protected: 00033 bool compute_p(vcl_vector<HomgPoint2D> const&, 00034 vcl_vector<HomgPoint2D> const&, 00035 HMatrix2D *); 00036 public: 00037 static HMatrix2D compute(const vcl_vector<HomgPoint2D>&p1, const vcl_vector<HomgPoint2D>&p2); 00038 static HMatrix2D compute(vcl_vector<vgl_homg_point_2d<double> > const& p1, 00039 vcl_vector<vgl_homg_point_2d<double> > const& p2); 00040 int minimum_number_of_correspondences() const { return 3; } 00041 // left in for capes : 00042 static HMatrix2D compute(const PairMatchSetCorner &matches); 00043 }; 00044 00045 //-------------------------------------------------------------------------------- 00046 00047 #include <vnl/vnl_matrix.h> 00048 // 00049 // This class takes an array of n HomgPoint2Ds and creates 00050 // an n-by-2 matrix whose ith row contains the inhomogeneous 00051 // coordinates of the ith homogeneous point. 00052 // 00053 struct NonHomg : public vnl_matrix<double> 00054 { 00055 NonHomg(const vcl_vector<HomgPoint2D> &A); 00056 NonHomg(vcl_vector<vgl_homg_point_2d<double> > const& A); 00057 }; 00058 00059 // 00060 // This function computes the mean of the columns of 00061 // an n-by-2 matrix A. 00062 // 00063 vnl_double_2 mean2(const vnl_matrix<double> &A); 00064 00065 00066 // 00067 // This function subtracts the 2-vector a from each row of 00068 // the n-by-2 matrix A. 00069 // 00070 vnl_matrix<double>& sub_rows(vnl_matrix<double> &A, const vnl_double_2 a); 00071 00072 //-------------------------------------------------------------------------------- 00073 00074 #endif // HMatrix2DAffineCompute_h_