MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / load_tracking_data

Function load_tracking_data

utils/viser_tracking_visualizer.py:126–163  ·  view source on GitHub ↗

Load tracking data and metadata from a file or directory.

(path: Path)

Source from the content-addressed store, hash-verified

124# ============================================================================
125
126def load_tracking_data(path: Path) -> tuple[list[dict], dict | None]:
127 """Load tracking data and metadata from a file or directory."""
128
129 # If path is a directory, look for tracking.jsonl
130 if path.is_dir():
131 tracking_file = path / "tracking.jsonl"
132 metadata_file = path / "metadata.json"
133 else:
134 tracking_file = path
135 metadata_file = path.parent / "metadata.json"
136
137 if not tracking_file.exists():
138 raise FileNotFoundError(f"Tracking file not found: {tracking_file}")
139
140 # Load tracking frames
141 frames = []
142 print(f"Loading tracking data from: {tracking_file}")
143 with open(tracking_file, "r") as f:
144 for i, line in enumerate(f):
145 line = line.strip()
146 if line:
147 try:
148 frames.append(json.loads(line))
149 except json.JSONDecodeError as e:
150 print(f"Warning: Failed to parse line {i+1}: {e}")
151 if i % 1000 == 0 and i > 0:
152 print(f" Loaded {i} frames...")
153
154 print(f"Loaded {len(frames)} frames total")
155
156 # Load metadata if available
157 metadata = None
158 if metadata_file.exists():
159 with open(metadata_file, "r") as f:
160 metadata = json.load(f)
161 print(f"Loaded metadata: duration={metadata.get('duration', 'N/A'):.1f}s")
162
163 return frames, metadata
164
165
166# ============================================================================

Callers 1

mainFunction · 0.70

Calls 3

printFunction · 0.50
stripMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected