了解decomposeProjectionMatrix

时间:2019-04-05 19:59:52

标签: opencv

函数decomposeProjectionMatrix()输出rotMatrix以及rotMatrX,rotMatrY和rotMatrz(以及其他数量)。

我的理解是rotMatrix = rotMatrX * rotMatrY * rotMatrZ(其中*是矩阵乘法运算符)。但是,结果并非如此。

这里是分解的一个例子。

# Decompose rotation vector using Rodridgues decomposition.
self.rotation_matrix, _ = cv2.Rodrigues(self.rotation_vector)

print("Rotation matrix returned from Rodrigues:\n", self.rotation_matrix)

# Combine the rotation matrix and translation vector to create pose matrix.
self.pose_matrix = cv2.hconcat((self.rotation_matrix, self.translation_vector))

# Decompose pose matrix in various properties.
properties = cv2.decomposeProjectionMatrix(self.pose_matrix)
self.projection_matrix = properties[0]
self.rot_matrix = properties[1]
self.trans_vect = properties[2]
self.rot_matrix_x = properties[3]
self.rot_matrix_y = properties[4]
self.rot_matrix_z = properties[5]
self.euler_angles = properties[6]

print("xyz\n",np.matmul(self.rot_matrix_x, np.matmul(self.rot_matrix_y, self.rot_matrix_z)))
print()
print("zyx\n",np.matmul(self.rot_matrix_z, np.matmul(self.rot_matrix_y, self.rot_matrix_x)))
print()
print("yxz\n",np.matmul(self.rot_matrix_y, np.matmul(self.rot_matrix_x, self.rot_matrix_z)))
print()
print(self.rot_matrix)

这是实际输出的示例:

Rotation matrix returned from Rodrigues:
 [[-0.00353424  0.99998718  0.00362615]
 [-0.145003   -0.00410033  0.98942272]
 [ 0.9894249   0.00297105  0.14501563]]
xyz
 [[-0.00353424 -0.145003    0.9894249 ]
 [ 0.99998718 -0.00410033  0.00297105]
[ 0.00362615  0.98942272  0.14501563]]

zyx
 [[-0.00353424 -0.99899952 -0.04458098]
 [ 0.145003   -0.04462205  0.98842451]
 [-0.9894249  -0.00297105  0.14501563]]

yxz
 [[-0.0237951  -0.14450917  0.98921731]
 [ 0.99949335 -0.02436119  0.02048349]
 [ 0.02113845  0.98920353  0.14501563]]

 [[-0.00353424  0.99998718  0.00362615]
 [-0.145003   -0.00410033  0.98942272]
 [ 0.9894249   0.00297105  0.14501563]]

我们看到xyz或zyx并没有给我们旋转矩阵! zyx几乎给了我们正确的结果,但是有负号错误!问题是什么!?!?谢谢!

0 个答案:

没有答案