Datasets:

Modalities:
Image
Video
Languages:
English
Size:
< 1K
Libraries:
Datasets
License:
lemonaddie commited on
Commit
f5b33e2
·
verified ·
1 Parent(s): 78b5d34

Update vis_trajectory.py

Browse files
Files changed (1) hide show
  1. vis_trajectory.py +17 -5
vis_trajectory.py CHANGED
@@ -35,15 +35,20 @@ if __name__ == '__main__' :
35
  for i, key in enumerate(data.keys()):
36
  if "C_" in key:
37
  cam_poses.append(parse_matrix(data[key]))
 
38
  cam_poses = np.stack(cam_poses)
39
  cam_poses = np.transpose(cam_poses, (0,2,1))
40
  cam_poses[:,:3,3] /= 100.
 
41
  relative_pose = np.linalg.inv(cam_poses[0])
 
 
 
 
 
42
  cam_num = len(cam_poses)
43
  for idx in range(cam_num):
44
  cam_pose = cam_poses[idx]
45
- cam_pose = cam_pose[:, [1,2,0,3]]
46
- cam_pose = relative_pose @ cam_pose
47
  cam_points_vis = get_cam_points_vis(W, H, intrinsics, cam_pose, [0.4, 0.4, 0.4], frustum_length=1.)
48
  vis_all.append(cam_points_vis)
49
 
@@ -59,12 +64,14 @@ if __name__ == '__main__' :
59
  obj_poses.append(parse_matrix(data[key][0]['matrix']))
60
  obj_poses = np.stack(obj_poses)
61
  obj_poses = np.transpose(obj_poses, (0,2,1))
62
-
63
  obj_poses[:,:3,3] -= translation
64
  obj_poses[:,:3,3] /= 100.
65
  obj_poses = obj_poses[:, :, [1,2,0,3]]
66
  obj_poses = relative_pose @ obj_poses
67
  obj_poses = obj_poses[frame_indices]
 
 
 
68
 
69
  obj_num = len(obj_poses)
70
  for idx in range(obj_num):
@@ -86,13 +93,16 @@ if __name__ == '__main__' :
86
  obj_poses = obj_poses[:, :, [1,2,0,3]]
87
  obj_poses = relative_pose @ obj_poses
88
  obj_poses = obj_poses[frame_indices]
 
 
 
89
  obj_num = len(obj_poses)
90
  for idx in range(obj_num):
91
  obj_pose = obj_poses[idx]
92
  if (idx % 5 == 0) :
93
  cam_points_vis = get_cam_points_vis(W, H, intrinsics, obj_pose, [0., 0.8,0.], frustum_length=0.5)
94
  vis_all.append(cam_points_vis)
95
-
96
  if len(data[key])>=3:
97
  with open('traj_vis/'+video_name, 'r') as file:
98
  data = json.load(file)
@@ -106,6 +116,9 @@ if __name__ == '__main__' :
106
  obj_poses = obj_poses[:, :, [1,2,0,3]]
107
  obj_poses = relative_pose @ obj_poses
108
  obj_poses = obj_poses[frame_indices]
 
 
 
109
  obj_num = len(obj_poses)
110
  for idx in range(obj_num):
111
  obj_pose = obj_poses[idx]
@@ -115,6 +128,5 @@ if __name__ == '__main__' :
115
 
116
  # vis coordinates
117
  axis = open3d.geometry.TriangleMesh.create_coordinate_frame(size=2, origin=[0,0,0])
118
- # vis_all.append(axis)
119
 
120
  open3d.visualization.draw_geometries(vis_all)
 
35
  for i, key in enumerate(data.keys()):
36
  if "C_" in key:
37
  cam_poses.append(parse_matrix(data[key]))
38
+
39
  cam_poses = np.stack(cam_poses)
40
  cam_poses = np.transpose(cam_poses, (0,2,1))
41
  cam_poses[:,:3,3] /= 100.
42
+ cam_poses = cam_poses[:,:,[1,2,0,3]]
43
  relative_pose = np.linalg.inv(cam_poses[0])
44
+ cam_poses = relative_pose @ cam_poses
45
+ # convert right-hand coord to left-hand coord
46
+ cam_poses[:,:3,3][:,1] *= -1.
47
+ cam_poses[:,:,:2] *= -1.
48
+
49
  cam_num = len(cam_poses)
50
  for idx in range(cam_num):
51
  cam_pose = cam_poses[idx]
 
 
52
  cam_points_vis = get_cam_points_vis(W, H, intrinsics, cam_pose, [0.4, 0.4, 0.4], frustum_length=1.)
53
  vis_all.append(cam_points_vis)
54
 
 
64
  obj_poses.append(parse_matrix(data[key][0]['matrix']))
65
  obj_poses = np.stack(obj_poses)
66
  obj_poses = np.transpose(obj_poses, (0,2,1))
 
67
  obj_poses[:,:3,3] -= translation
68
  obj_poses[:,:3,3] /= 100.
69
  obj_poses = obj_poses[:, :, [1,2,0,3]]
70
  obj_poses = relative_pose @ obj_poses
71
  obj_poses = obj_poses[frame_indices]
72
+ # convert right-hand coord to left-hand coord
73
+ obj_poses[:,:3,3][:,1] *= -1.
74
+ obj_poses[:,:,:2] *= -1.
75
 
76
  obj_num = len(obj_poses)
77
  for idx in range(obj_num):
 
93
  obj_poses = obj_poses[:, :, [1,2,0,3]]
94
  obj_poses = relative_pose @ obj_poses
95
  obj_poses = obj_poses[frame_indices]
96
+ # convert right-hand coord to left-hand coord
97
+ obj_poses[:,:3,3][:,1] *= -1.
98
+ obj_poses[:,:,:2] *= -1.
99
  obj_num = len(obj_poses)
100
  for idx in range(obj_num):
101
  obj_pose = obj_poses[idx]
102
  if (idx % 5 == 0) :
103
  cam_points_vis = get_cam_points_vis(W, H, intrinsics, obj_pose, [0., 0.8,0.], frustum_length=0.5)
104
  vis_all.append(cam_points_vis)
105
+
106
  if len(data[key])>=3:
107
  with open('traj_vis/'+video_name, 'r') as file:
108
  data = json.load(file)
 
116
  obj_poses = obj_poses[:, :, [1,2,0,3]]
117
  obj_poses = relative_pose @ obj_poses
118
  obj_poses = obj_poses[frame_indices]
119
+ # convert right-hand coord to left-hand coord
120
+ obj_poses[:,:3,3][:,1] *= -1.
121
+ obj_poses[:,:,:2] *= -1.
122
  obj_num = len(obj_poses)
123
  for idx in range(obj_num):
124
  obj_pose = obj_poses[idx]
 
128
 
129
  # vis coordinates
130
  axis = open3d.geometry.TriangleMesh.create_coordinate_frame(size=2, origin=[0,0,0])
 
131
 
132
  open3d.visualization.draw_geometries(vis_all)