3
$\begingroup$

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.
$\endgroup$
1
$\begingroup$

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.


To address your questions one by one:

  1. They are in pixel coordinates and denote the principal point (computed center of the image).
  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.
  3. Use the explanation I already provided (above).

And additionally, it is not an affine transformation, it's a projective mapping (perspective transformation). In fact homography is nothing more than the transformation of one plane to another.

$\endgroup$
  • $\begingroup$ I am using simulated images perpendicular to the scene (not an actual camera that could be typically calibrated), with known altitude and FOV. Is considering K as an identity matrix a mistake? $\endgroup$ – Parlance Sep 21 '15 at 0:53
  • $\begingroup$ I put this new question in this other dsp post $\endgroup$ – Parlance Sep 21 '15 at 2:18
  • $\begingroup$ Doesn't matter. If you know FOV and image dimensions, you could get the camera matrix. Updated my answer. Second one is a totally different question and I'll answer that separately. $\endgroup$ – Tolga Birdal Sep 21 '15 at 7:25
  • $\begingroup$ So, once E is obtained, how do you extract information of the scaling between images? And what is the next step to compute the motion of the camera pose -combining rot. angle, translation and scaling- ? $\endgroup$ – Parlance Sep 22 '15 at 8:13
  • $\begingroup$ 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. $\endgroup$ – Tolga Birdal Feb 18 '16 at 12:01

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.