stray_visualize_2.py 808 B

123456789101112131415161718
  1. def read_data(flags):
  2. intrinsics = np.loadtxt(os.path.join(flags.path, 'camera_matrix.csv'), delimiter=',')
  3. odometry = np.loadtxt(os.path.join(flags.path, 'odometry.csv'), delimiter=',', skiprows=1)
  4. poses = []
  5. for line in odometry:
  6. # timestamp, frame, x, y, z, qx, qy, qz, qw
  7. position = line[2:5]
  8. quaternion = line[5:]
  9. T_WC = np.eye(4)
  10. T_WC[:3, :3] = Rotation.from_quat(quaternion).as_matrix()
  11. T_WC[:3, 3] = position
  12. poses.append(T_WC)
  13. depth_dir = os.path.join(flags.path, 'depth')
  14. depth_frames = [os.path.join(depth_dir, p) for p in sorted(os.listdir(depth_dir))]
  15. depth_frames = [f for f in depth_frames if '.npy' in f or '.png' in f]
  16. return { 'poses': poses, 'intrinsics': intrinsics, 'depth_frames': depth_frames }