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