The homography transformation is based on the following formulae[4]:
homography formula

The Homography transformation

A Homography is a transformation ( a 3×3 matrix ) that maps the points

in one image to the corresponding points in the other image.[5]

\[ H = \left[ \begin{array}{ccc} h_{00} & h_{01} & h_{02} \\ h_{10} & h_{11} & h_{12} \\ h_{20} & h_{21} & h_{22} \end{array} \right] \]

\[ \left[ \begin{array}{c} x_1 \\ y_1 \\ 1 \end{array} \right] &= H \left[ \begin{array}{c} x_2 \\ y_2 \\ 1 \end{array} \right] &= \left[ \begin{array}{ccc} h_{00} & h_{01} & h_{02} \\ h_{10} & h_{11} & h_{12} \\ h_{20} & h_{21} & h_{22} \end{array} \right] \left[ \begin{array}{c} x_2 \\ y_2 \\ 1 \end{array} \right] \]

homography example

Image Alignment Using Homography


Image Alignment using Homography

Translation[6]

translation.jpg

Rotation[6]

rotation.jpg

Affine Transformation[6]

affine.jpg

Perspective Transformation[6]

perspective.jpg

-------------------------------------------------------

How to find angle between two images[10]

cv::Point3d findOrientation(const cv::Mat& src){
      cv::Moments m = cv::moments(src, true);
      double cen_x=m.m10/m.m00;
      double cen_y=m.m01/m.m00;
     double m_11= 2*m.m11-m.m00*(cen_x*cen_x+cen_y*cen_y);// m.mu11/m.m00;    
     double m_02=m.m02-m.m00*cen_y*cen_y;// m.mu02/m.m00;
     double m_20=m.m20-m.m00*cen_x*cen_x;//m.mu20/m.m00;    
     double theta = m_20==m_02?0:atan2(m_11, m_20-m_02)/2.0;
    //  theta = (theta / PI) * 180.0; //if you want in radians.(or vice versa, not sure)
    return cv::Point3d(cen_x,cen_y,theta);
}


參考資料

1. OpenCV: Fitting an object into a scene using homography and perspective transform in Java

2. Sector Projection Fourier Descriptor

3. Affine Transformations

4. The Homography transformation

5. Homography Examples using OpenCV ( Python / C ++ )

6. Geometric Transformations of Images

7. Features2D + Homography to find a known object

8. scale and rotation Template matching

9. How to find the rotated angle of object

10.How to find angle between two images

11. Real-time object detection in OpenCV using SURF

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()