# Obtain motion between image features by means of the homography matrix

I have been reading several really good answers about how to obtain camera pose (rotation, translation, etc), such as this one and this one, but I am not sure how this applies to my problem.

• My problem: I have two images of a planar scene (terrain image from above), and I want find the motion that the camera has experienced between the two images $(dx, dy)$.
• What I have done: I have image1 and image2 of a terrain with their features matched, and obtained its homography via OpenCV's C++ function:

cv::Mat H = cv::findHomography(image1points, image2points, CV_RANSAC);

Which looks like it is indeed an affine transformation: $$\pmatrix{a&b&c\\d&e&f\\0&0&1}$$

• What I need help with:

1. In this matrix, I don't know what is the reference frame of the $dx$, $dy$ parameters. $(dx, dy) = (c, f)$
2. How can I extract the rotation angle and scaling factor between the 2D axes of the two images. (Right now I am using this suggestion, but results don't seem reliable).
3. Once I have all the four parameters: $dx$, $dy$, rotation angle, scaling. How can I actually compute the motion of the camera (between the images) using the first image's axes as my reference frame.

First, calibrate your intrinsics: The focal lengths and the principal point. Homography is not really a rigid transformation and rather a mapping of a plane onto another one. What you really need is a 6DOF parametrization, which is the camera pose. If you have the intrinsics, you could transfer your coordinates to the normalized coordinates and estimate the essential matrix using 8 point algorithm - or a better one would be five point algorithm (check this, this and this). The operation is the same as solving for fundamental matrix in the uncalibrated setting. But, just because you have your $K$, you could recover essential matrix. Note that, such estimation doesn't assume planar scenes and can in fact operate on 3D structures.

You could then decompose your essential matrix as

$$E=R[t]_x$$ where $[t]_x$ is the skew symmetric form. To obtain the components, proceed as described in here. Note that, this problem has 4 possible solutions and identifying the best one is usually found via checking all solutions.

If your cameras are uncalibrated, you could maybe approximate the calibration using some known dimensions or a grid, within the scene.

If you are using simulated images, then you know the FOV and image dimensions. If this is the case, you could get the camera matrix. Or even better, if you have your $K$ matrix (you could artificially make up one), then you could compute the OpenGL equivalent. Check here and here for that.

2. Unfortunately, $E$ is defined up to a scale and you could only recover the scale, if you have a known object with size within the scene. You just need to know one distance to do this. It could be a marker, the length of some existing furniture, or the object you inspect and etc.