13
$\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...

$\endgroup$
  • $\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 Apr 23 '13 at 21:58
7
$\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$
  • $\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$ – Muhammet Ali Asan Jun 12 '15 at 13:58
  • $\begingroup$ Are you using the pose of A ? It seems that you're only using the input H $\endgroup$ – Guig Jun 21 '17 at 14:19
3
$\begingroup$

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

$\endgroup$
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, privacy policy and cookie policy

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