abreza commited on
Commit
ff92963
·
verified ·
1 Parent(s): 3533c8c

Update visualization/logger.py

Browse files
Files changed (1) hide show
  1. visualization/logger.py +12 -11
visualization/logger.py CHANGED
@@ -17,7 +17,7 @@ def create_subject_box(frame: Dict, dimensions: Dict) -> Dict[str, np.ndarray]:
17
  class SimulationLogger:
18
  def __init__(self):
19
  rr.init("camera_simulation")
20
- rr.log("world", rr.ViewCoordinates.RIGHT_HAND_Y_UP, timeless=True)
21
 
22
  self.K = np.array([
23
  [500, 0, 960],
@@ -40,7 +40,7 @@ class SimulationLogger:
40
  f" Subject Index: {inst.get('subjectIndex', 'N/A')}"
41
  for i, inst in enumerate(instructions)
42
  ])
43
- ), timeless=True)
44
 
45
  def log_subjects(self, subjects: List[Dict[str, Any]], frame_idx: int = 0) -> None:
46
  if not subjects:
@@ -90,8 +90,7 @@ class SimulationLogger:
90
  camera_positions,
91
  colors=np.full((len(camera_positions), 4),
92
  [0.0, 0.8, 0.8, 1.0])
93
- ),
94
- timeless=True
95
  )
96
 
97
  if len(camera_positions) > 1:
@@ -102,17 +101,21 @@ class SimulationLogger:
102
  rr.LineStrips3D(
103
  lines,
104
  colors=[(0.0, 0.8, 0.8, 1.0)]
105
- ),
106
- timeless=True
107
  )
108
 
109
  except Exception as e:
110
  print(f"Error logging camera trajectory: {str(e)}")
111
 
112
- def log_camera_frames(self, camera_frames: List[Dict[str, Any]], subjects: List[Dict[str, Any]]) -> None:
 
113
  if not camera_frames:
114
  return
115
 
 
 
 
 
116
  for frame_idx, camera_frame in enumerate(camera_frames):
117
  try:
118
  rr.set_time_sequence("frame_idx", frame_idx)
@@ -156,8 +159,7 @@ class SimulationLogger:
156
  helper_positions,
157
  radii=np.full(len(helper_positions), 0.03),
158
  colors=np.full((len(helper_positions), 4), [1.0, 1.0, 0.0, 1.0]),
159
- ),
160
- timeless=True
161
  )
162
 
163
  for keyframe_idx, helper_keyframe in enumerate(helper_keyframes):
@@ -171,8 +173,7 @@ class SimulationLogger:
171
  translation=position,
172
  rotation=rr.Quaternion(xyzw=rotation_q),
173
  scale=(.5, .5, .5)
174
- ),
175
- timeless=True
176
  )
177
 
178
  rr.log(
 
17
  class SimulationLogger:
18
  def __init__(self):
19
  rr.init("camera_simulation")
20
+ rr.log("world", rr.ViewCoordinates.RIGHT_HAND_Y_UP)
21
 
22
  self.K = np.array([
23
  [500, 0, 960],
 
40
  f" Subject Index: {inst.get('subjectIndex', 'N/A')}"
41
  for i, inst in enumerate(instructions)
42
  ])
43
+ ))
44
 
45
  def log_subjects(self, subjects: List[Dict[str, Any]], frame_idx: int = 0) -> None:
46
  if not subjects:
 
90
  camera_positions,
91
  colors=np.full((len(camera_positions), 4),
92
  [0.0, 0.8, 0.8, 1.0])
93
+ )
 
94
  )
95
 
96
  if len(camera_positions) > 1:
 
101
  rr.LineStrips3D(
102
  lines,
103
  colors=[(0.0, 0.8, 0.8, 1.0)]
104
+ )
 
105
  )
106
 
107
  except Exception as e:
108
  print(f"Error logging camera trajectory: {str(e)}")
109
 
110
+ def log_simulation(self, camera_frames: List[Dict[str, Any]], subjects: List[Dict[str, Any]]) -> None:
111
+ """Main method to log both camera frames and subjects"""
112
  if not camera_frames:
113
  return
114
 
115
+ # First log the camera trajectory
116
+ self.log_camera_trajectory(camera_frames)
117
+
118
+ # Then log each frame with its corresponding subject positions
119
  for frame_idx, camera_frame in enumerate(camera_frames):
120
  try:
121
  rr.set_time_sequence("frame_idx", frame_idx)
 
159
  helper_positions,
160
  radii=np.full(len(helper_positions), 0.03),
161
  colors=np.full((len(helper_positions), 4), [1.0, 1.0, 0.0, 1.0]),
162
+ )
 
163
  )
164
 
165
  for keyframe_idx, helper_keyframe in enumerate(helper_keyframes):
 
173
  translation=position,
174
  rotation=rr.Quaternion(xyzw=rotation_q),
175
  scale=(.5, .5, .5)
176
+ )
 
177
  )
178
 
179
  rr.log(