在保存为4D numpy数组的视频中,我具有人的姿势(如左肘,右膝盖等关节的X,Y,Z值)。
示例:姿势保存在形状为3、103、25、2的数组中,表示: 3(坐标数),103(帧数),25(关节数),2(人数)。
现在,我想更改此观察的视角。即我要在所有关节位置值上应用旋转矩阵。
到目前为止,我是
seq = np.random.rand(3, 103, 25, 2)
rot_mat = np.random.rand(3,3)
rotated_seq = np.zeros(seq.shape)
for i in range(seq.shape[3]): # iterating through person
person = seq[:, :, :, i]
joint_values = np.reshape(person, (3, -1))
rotated_joint_values = np.dot(joint_values.T, rot_mat).T
rotated_person = np.reshape(rotated_joint_values, person.shape)
rotated_seq[:, :, :, i] = rotated_person
我的问题是不使用for循环就可以执行任何操作。