| Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
Homography33.hGo to the documentation of this file.00001 //-*-c++-*- 00002 00003 #ifndef HOMOGRAPHY33_H 00004 #define HOMOGRAPHY33_H 00005 00006 #include <utility> 00007 00008 #include "Shared/fmat.h" 00009 00010 //! Compute 3x3 homography using Direct Linear Transform 00011 /* 00012 * y = Hx (y = image coordinates in homogeneous coordinates, H = 3x3 00013 * homography matrix, x = homogeneous 2D world coordinates) 00014 * 00015 * For each point correspondence, constrain y x Hx = 0 (where x is 00016 * cross product). This means that they have the same direction, and 00017 * ignores scale factor. 00018 * 00019 * We rewrite this as Ah = 0, where h is the 9x1 column vector of the 00020 * elements of H. Each point correspondence gives us 3 equations of 00021 * rank 2. The solution h is the minimum right eigenvector of A, 00022 * which we can obtain via SVD, USV' = A. h is the right-most column 00023 * of V'. 00024 * 00025 * We will actually maintain A'A internally, which is 9x9 regardless 00026 * of how many correspondences we're given, and has the same 00027 * eigenvectors as A. 00028 */ 00029 class Homography33 { 00030 public: 00031 //! Constructor 00032 Homography33(const std::pair<float,float> &opticalCenter); 00033 00034 //! Note that the returned H matrix does not reflect cxy. 00035 fmat::Matrix<3,3>& getH(); 00036 00037 const std::pair<float,float> getCXY() const { return cxy; } 00038 00039 void addCorrespondence(float worldx, float worldy, float imagex, float imagey); 00040 00041 void compute(); 00042 00043 std::pair<float,float> project(float worldx, float worldy); 00044 00045 private: 00046 std::pair<float,float> cxy; 00047 fmat::Matrix<9,9> fA; 00048 fmat::Matrix<3,3> H; 00049 bool valid; 00050 }; 00051 00052 #endif |
|
Tekkotsu v5.1CVS |
Generated Fri Mar 16 05:26:41 2012 by Doxygen 1.6.3 |