我有一个深度学习模型,它根据相机给出我的三维对象的平移和旋转矩阵。我想使用python在x轴上旋转和细化对象(比如说5度(。我该怎么办?
rotation_matrix = [[ 0.99781346 -0.06608013 -0.00129879]
[ 0.00725005 0.12896627 -0.99162245]
[ 0.06569404 0.98944485 0.12916337]]
translation_matrix = [[-13.7971115]
[ -7.9274826]
[423.7128 ]]
提前感谢
我找到了答案。你需要导入scipy
from scipy.spatial.transform import Rotation
### first transform the matrix to euler angles
r = Rotation.from_matrix(rotation_matrix)
angles = r.as_euler("zyx",degrees=True)
#### Modify the angles
print(angles)
angles[0] += 5
#### Then transform the new angles to rotation matrix again
r = Rotation.from_euler("zyx",angles,degrees=True)
new_rotation_matrix = new_r.as_matrix()