15
$\begingroup$

Say I use only one calibrated camera. From this camera, I get images A and B. I know the homography between A and B, computed through OpenCV's findHomography().

I know the pose (rotation matrix R and translation vector t) of image A, and I need the pose of image B. Once I get it, I suppose I'll be able to compute every further poses of following images.

Do you know an implementation of computing B's pose? I found several articles on the web, but I couldn't find an easily implementable solution...


I found a nice implementation, using OpenCV: http://nghiaho.com/?p=1298

$\endgroup$
1
  • $\begingroup$ I'm not sure that I understand how to use your code. I use OpenCV to retrieve the Homography, but when I send that Homography through the algorithm, it always returns this. cameraPose [1, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0] $\endgroup$
    – LeRoss
    Commented Apr 23, 2013 at 21:58

2 Answers 2

8
$\begingroup$

Even if my answer comes too late for you, maybe other people find this useful. I have the codes for an openCV Pose from Homography. I found the method at this really useful website, euclideanspace.

void cameraPoseFromHomography(const Mat& H, Mat& pose)
{
    pose = Mat::eye(3, 4, CV_64FC1); //3x4 matrix
    float norm1 = (float)norm(H.col(0)); 
    float norm2 = (float)norm(H.col(1));
    float tnorm = (norm1 + norm2) / 2.0f;

    Mat v1 = H.col(0);
    Mat v2 = pose.col(0);

    cv::normalize(v1, v2); // Normalize the rotation

    v1 = H.col(1);
    v2 = pose.col(1);

    cv::normalize(v1, v2);

    v1 = pose.col(0);
    v2 = pose.col(1);

    Mat v3 = v1.cross(v2);  //Computes the cross-product of v1 and v2
    Mat c2 = pose.col(2);
    v3.copyTo(c2);      

    pose.col(3) = H.col(2) / tnorm; //vector t [R|t]
}

////

$\endgroup$
3
  • $\begingroup$ I have used your function in my code.Pose matrix computed using this way is always being [1 0 0 0; 0 1 0 0;0 0 1 0;0 0 0 0] . Do you have any explanation ? $\endgroup$ Commented Jun 12, 2015 at 13:58
  • $\begingroup$ Are you using the pose of A ? It seems that you're only using the input H $\endgroup$
    – Guig
    Commented Jun 21, 2017 at 14:19
  • $\begingroup$ This method is not really accurate, even with a homography matrix computed straight from a known pose. The result can be improved, though, using an iterative process where you get a matrix from the estimated pose, invert it and apply to the original input. Get the pose parameters from this residue homography, update your pose estimate and so on until it converges. $\endgroup$ Commented Feb 2, 2020 at 22:56
0
$\begingroup$

You can use Homography decomposition method implemented in Opencv 3.0+

decomposeHomographyMat

  • Opencv’s function returns set of possible rotations, camera normals and translation matrices.
  • You have to select correct set among them by comparing camera normals with camera normal of camera when first image was captured
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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