(self, frames: list[dict], metadata: dict | None = None)
| 304 | """Interactive visualizer for tracking data.""" |
| 305 | |
| 306 | def __init__(self, frames: list[dict], metadata: dict | None = None): |
| 307 | self.frames = frames |
| 308 | self.metadata = metadata |
| 309 | |
| 310 | # Parse extrinsic calibration (may be stored as JSON string) |
| 311 | self.extrinsic = None |
| 312 | if metadata: |
| 313 | ext_data = metadata.get("extrinsicCalibration") |
| 314 | if ext_data: |
| 315 | if isinstance(ext_data, str): |
| 316 | # Parse JSON string |
| 317 | self.extrinsic = json.loads(ext_data) |
| 318 | else: |
| 319 | self.extrinsic = ext_data |
| 320 | |
| 321 | # Print calibration details |
| 322 | print_calibration_info(self.extrinsic) |
| 323 | |
| 324 | self.current_frame = 0 |
| 325 | self.azim = -60 # Horizontal rotation angle (around Y axis) |
| 326 | |
| 327 | # Set up figure |
| 328 | self.fig = plt.figure(figsize=(14, 10)) |
| 329 | self.ax = self.fig.add_subplot(111, projection='3d') |
| 330 | |
| 331 | # Add slider for frame selection |
| 332 | slider_ax = self.fig.add_axes([0.2, 0.02, 0.6, 0.03]) |
| 333 | self.slider = Slider(slider_ax, 'Frame', 0, len(frames) - 1, |
| 334 | valinit=0, valstep=1) |
| 335 | self.slider.on_changed(self.update_frame) |
| 336 | |
| 337 | # Track mouse for rotation |
| 338 | self.last_mouse_x = None |
| 339 | self.is_dragging = False |
| 340 | self.fig.canvas.mpl_connect('button_press_event', self.on_mouse_press) |
| 341 | self.fig.canvas.mpl_connect('button_release_event', self.on_mouse_release) |
| 342 | self.fig.canvas.mpl_connect('motion_notify_event', self.on_mouse_move) |
| 343 | |
| 344 | # Initial draw |
| 345 | self.update_frame(0) |
| 346 | |
| 347 | # Set up keyboard navigation |
| 348 | self.fig.canvas.mpl_connect('key_press_event', self.on_key) |
| 349 | |
| 350 | def on_mouse_press(self, event): |
| 351 | """Handle mouse button press.""" |
nothing calls this directly
no test coverage detected