Homography33.h
Go to the documentation of this file.
00001 //-*-c++-*-
00002 
00003 #ifndef HOMOGRAPHY33_H
00004 #define HOMOGRAPHY33_H
00005 
00006 #include <utility>
00007 #include <vector>
00008 
00009 #include <Eigen/Dense>
00010 
00011 // interpolate points instead of using homography
00012 #define INTERPOLATE
00013 // use stable version of homography recover (opencv, includes refinement step)
00014 #define STABLE_H
00015 
00017 /*
00018  *
00019  *  DEPRECATED - DEPRECATED - DEPRECATED - DEPRECATED
00020  *
00021  *  use TagDetection::getRelativeTransform() instead
00022  *
00023  *
00024  *  y = Hx (y = image coordinates in homogeneous coordinates, H = 3x3
00025  *  homography matrix, x = homogeneous 2D world coordinates)
00026  *
00027  *  For each point correspondence, constrain y x Hx = 0 (where x is
00028  *  cross product). This means that they have the same direction, and
00029  *  ignores scale factor.
00030  *
00031  *  We rewrite this as Ah = 0, where h is the 9x1 column vector of the
00032  *  elements of H. Each point correspondence gives us 3 equations of
00033  *  rank 2. The solution h is the minimum right eigenvector of A,
00034  *  which we can obtain via SVD, USV' = A. h is the right-most column
00035  *  of V'.
00036  *
00037  *  We will actually maintain A'A internally, which is 9x9 regardless
00038  *  of how many correspondences we're given, and has the same
00039  *  eigenvectors as A.
00040  */
00041 class Homography33 {
00042 public:
00044   Homography33(const std::pair<float,float> &opticalCenter);
00045 
00046 #ifdef STABLE_H
00047   void setCorrespondences(const std::vector< std::pair<float,float> > &srcPts,
00048                           const std::vector< std::pair<float,float> > &dstPts);
00049 #else
00050   void addCorrespondence(float worldx, float worldy, float imagex, float imagey);
00051 #endif
00052 
00054   Eigen::Matrix3d& getH();
00055 
00056   const std::pair<float,float> getCXY() const { return cxy; }
00057 
00058   void compute();
00059 
00060   std::pair<float,float> project(float worldx, float worldy);
00061 
00062 private:
00063   std::pair<float,float> cxy;
00064   Eigen::Matrix<double,9,9> fA;
00065   Eigen::Matrix3d H;
00066   bool valid;
00067 #ifdef STABLE_H
00068   std::vector< std::pair<float,float> > srcPts, dstPts;
00069 #endif
00070 };
00071 
00072 #endif


apriltags
Author(s): Michael Kaess, Hordur Johannson
autogenerated on Thu Jun 6 2019 20:53:23