Estimate camera pose from homography?

asked 2020-09-10 05:48:17 -0500

RashidLadj gravatar image

Hello, having two non-planar images, I am trying to estimate the pose of the camera using the homography matrix (which normally is used for planar images), the fundamental matrix, and the essential matrix. In the first case, I am interested in the homography matrix.

So I had to use one of the descriptors exiting on openCV (Sift, Surf, ORB, Akaze), before matching the feature points (using FLANN or BFMatcher), then I calculated the homography matrix with findHomographyMat using Ransac or other. once I have the homography matrix, I decompose it using decomposeHomographyMat which returns 4 possible cases of transformation (Rotation matrix, translation vector, and Normal vector)

in order to confirm that the result is correct, we can recompose the homography matrix using the transformations given by decomposeHomographyMat using the following formula:

    NumberOfResult, self.Rs, self.Ts, self.Ns = cv.decomposeHomographyMat(self.H, np.eye(3))
    # /** H = Rs + Ts * Ns.T **/ #
    # /** Nomalize H --> H = H / H(2,2) **/ #
    for i in range (NumberOfResult):
        recomputeH = Rs[i] + np.dot(Ts[i], Ns[i].T)
        norm = recomputeH[2][2]
        recomputeH = (1 / norm) * recomputeH
        # Just for confirmation result 
        print (np.array_equal(np.around(self.H, decimals=4), np.around(recomputeH, decimals=4)))

now having this transformation, I would like to assign a 3d position to camera 1, and assign it the transformation to have the pose of camera 2, and I don't know how to do that, if anyone has any idea, please answer me

edit retag flag offensive close merge delete

Comments

I don't understand. You have two non-planar scenes and you are aware that Homography transformation holds only for planar scene (or for pure camera rotation movement).

Anyway, there are some test code here.

Eduardo gravatar imageEduardo ( 2020-09-10 06:51:32 -0500 )edit