简体   繁体   中英

SVD not giving Rotation and Translation matrix from stereo essential matrix

I am trying to extract rotation and translation from the fundamental matrix. I used the intrinsic matrices to get the essential matrix, but the SVD is not giving expected results. So I composed the essential matrix and trying my SVD code to get the Rotation and translation matrices back and found that the SVD code is wrong.

I created the essential matrix using Rotation and translation matrices

R = [[ 0.99965657,  0.02563432, -0.00544263],
        [-0.02596087,  0.99704732, -0.07226806],
        [ 0.00357402,  0.07238453,  0.9973704 ]]
T = [-0.1679611706725666, 0.1475313058767286, -0.9746915198833979]
tx = np.array([[0, -T[2], T[1]], [T[2], 0, -T[0]], [-T[1], T[0], 0]])
E = R.dot(tx)
// E Output: [[-0.02418259,  0.97527093,  0.15178621],
        [-0.96115177, -0.01316561,  0.16363519],
        [-0.21769595, -0.16403593,  0.01268507]]

Now while trying to get it back using SVD.

U,S,V = np.linalg.svd(E)
diag_110 = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 0]])
newE = U.dot(diag_110).dot(V.T)
U,S,V = np.linalg.svd(newE)

W = np.array([[0, -1, 0], [1, 0, 0], [0, 0, 1]])
Z = np.array([[0, 1, 0],[-1,  0,  0],[0,  0,  0]])

R1 = U.dot(W).dot(V.T)
R2 = U.dot(W.T).dot(V.T)

T  = U.dot(Z).dot(U.T);
T = [T[1,0], -T[2, 0], T[2, 1]]

'''
Output
R1 :   [[-0.99965657, -0.00593909,  0.02552386],
        [ 0.02596087, -0.35727319,  0.93363906],
        [-0.00357402, -0.93398105, -0.35730468]]
R2 :   [[-0.90837444, -0.20840016, -0.3625262 ],
        [ 0.26284261,  0.38971602, -0.8826297 ],
        [-0.32522244,  0.89704559,  0.29923163]]
T :    [-0.1679611706725666, 0.1475313058767286, -0.9746915198833979],
'''

What is wrong with the SVD code? I referred the code here and here

Your R1 output is a left-handed and axis-permuted version of your initial (ground-truth) rotation matrix: notice that the first column is opposite to the ground-truth, and the second and third are swapped, and that the determinant of R1 is ~= -1 (ie it's a left-handed frame).

The reason this happens is that the SVD decomposition returns unitary matrices U and V with no guaranteed parity. In addition, you multiplied by an axis-permutation matrix W. It is up to you to flip or permute the axes so that the rotation has the correct handedness. You do so by enforcing constraints from the images and the scene, and known order of the cameras (ie knowing which camera is the left one).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM