What is the link between the homography computed over 2 images and the homography computed over the same images upside down?

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

and

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:

and

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).
• 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 – Stéphane Péchard Mar 28 '12 at 7:42