-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
import numpy as np
import json
from scipy.spatial.transform import Rotation as R
def parse_matrix(matrix_str):
rows = matrix_str.strip().split('] [')
matrix = []
for row in rows:
row = row.replace('[', '').replace(']', '')
matrix.append(list(map(float, row.split())))
return np.array(matrix)
tgt_camera_path = "my_example_test_data/cameras/camera_extrinsics.json"
with open(tgt_camera_path, 'r') as file:
cam_data = json.load(file)
cam_idx = list(range(5))[::4]
traj = [parse_matrix(cam_data[f"frame{idx}"]["cam01"]) for idx in cam_idx]
print( traj )
traj = np.stack(traj).transpose(0, 2, 1)
print( traj )
c2ws = []
for c2w in traj:
c2w = c2w[:, [1, 2, 0, 3]]
c2w[:3, 1] *= -1.
c2w[:3, 3] /= 100
c2ws.append(c2w)
print( c2ws )
``` 我用上面的代码运行的c2ws的结果是,这个结果的旋转矩阵并不是单位矩阵。我想问一下是我哪里写的有问题吗还是本身是这样设置的?Metadata
Metadata
Assignees
Labels
No labels