简体   繁体   English

SVD不从立体基本矩阵给出旋转和平移矩阵

[英]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.我使用内在矩阵来获得基本矩阵,但 SVD 没有给出预期的结果。 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.所以我组合了基本矩阵并尝试我的 SVD 代码来获取旋转和平移矩阵,发现 SVD 代码是错误的。

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.现在尝试使用 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? SVD 代码有什么问题? 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).您的 R1 输出是初始(地面实况)旋转矩阵的左手和轴置换版本:注意第一列与地面实况相反,第二列和第三列交换,并且R1 是 ~= -1(即它是一个左手框架)。

The reason this happens is that the SVD decomposition returns unitary matrices U and V with no guaranteed parity.发生这种情况的原因是 SVD 分解返回没有保证奇偶性的酉矩阵 U 和 V。 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.此外,您乘以轴置换矩阵 W。由您来翻转或置换轴,以便旋转具有正确的旋向性。 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).您可以通过强制执行图像和场景中的约束以及已知的摄像机顺序(即知道哪个摄像机是左边的)来实现这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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