With OpenCV, I compute the homography between, say, these two images:

first image


second image

Don't worry about the strange white form on the right side, it is due to the smartphone holder I use. The homography, given by findHomography() function (using points detected with the Fast feature detector and the HammingLUT descriptor matcher), is:

A = [ 1.412817430564191,  0.0684947165270289,  -517.7751355800591;
     -0.002927297251810,  1.210310757993256,     39.56631316477566;
      0.000290600259844, -9.348301989015293e-05,  1]

Now, I use the same process to compute the homography between the same images that have been rotated by 180 degrees (upside down), using imagemagick (as a matter of fact, I would be equally interested to know the relation for rotation of 90 or 270 degrees...). Here they are:

first image upside down


second image upside down

With these images, the homography becomes:

B = [ 0.7148688519736168,  0.01978048500375845,  325.8330631554814;
     -0.1706219498833541,  0.8666521745094313,    64.72944905752504;
     -0.0002078857275647, -5.080048486810413e-05,  1]

Now, the question is how do you relate A and B? The two first diagonal values of A are close to the inverse of the same in B, but it's not very precise (.707805537 instead of 0.71486885). My ultimate purpose would to use the wanted relation to transform final matrix, avoiding to compute a costly image rotation.


I think when looking at the formula for the homography matrix: $$ H_{ba} = R - \frac{tn^T}{d} $$ where $R$ is the rotation matrix by which $b$ is rotated in relation to $a$; $t$ is the translation vector from $a$ to $b$; $n$ and $d$ are the normal vector of the plane and the distance to the plane respectively (see Homography-3D plane to plane equation).

The relation between the two matrices lies in the normal vector of the plane. So you need to get the normal vector of the plane (out of the homography matrix), and apply the rotation to it, and then compute the homography matrix using the formula above. For the correct decomposing of the homography matrix, you can look at these code samples and this paper.

| improve this answer | |
  • $\begingroup$ I don't really get what you mean. From the equation, I got the normal with Mat invT = 1./t; Mat n = invT.t() * (H - R); (actually, it's n/d). Now, "applying the rotation to it" gives me a 3x1 vector, but how can I use it to compute the homography matrix again? Thanks $\endgroup$ – Stéphane Péchard Mar 28 '12 at 7:42
  • $\begingroup$ Added more info, hope that makes it clear. $\endgroup$ – Geerten Mar 28 '12 at 9:16
  • $\begingroup$ why it's - t/d and not +t/d? $\endgroup$ – Maystro Jun 23 '15 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.