Skip to content

camera trajectory #74

@mo230761

Description

@mo230761
Image
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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions