MCPcopy Create free account
hub / github.com/ecto/muni / load_session_data

Function load_session_data

depot/splat-worker/src/worker.py:205–311  ·  view source on GitHub ↗

Load session data for splatting. Returns: points: (N, 3) array of LiDAR points in world frame poses: List of camera poses with timestamps images: List of image paths

(session_path: Path)

Source from the content-addressed store, hash-verified

203
204
205def load_session_data(session_path: Path) -> tuple[np.ndarray, list[dict], list[Path]]:
206 """
207 Load session data for splatting.
208
209 Returns:
210 points: (N, 3) array of LiDAR points in world frame
211 poses: List of camera poses with timestamps
212 images: List of image paths
213 """
214 logger.info(f"Loading session from {session_path}")
215
216 # Load poses first
217 poses = load_poses(session_path)
218
219 # Load LiDAR timestamps
220 lidar_dir = session_path / 'lidar'
221 lidar_timestamps = {}
222
223 timestamps_file = lidar_dir / 'timestamps.csv' if lidar_dir.exists() else None
224 if timestamps_file and timestamps_file.exists():
225 with open(timestamps_file, 'r') as f:
226 next(f) # Skip header
227 for line in f:
228 parts = line.strip().split(',')
229 if len(parts) >= 2:
230 frame_num = int(parts[0])
231 timestamp = float(parts[1])
232 lidar_timestamps[frame_num] = timestamp
233
234 # Load LiDAR points with pose transformation
235 points = []
236
237 if lidar_dir.exists():
238 pcd_files = sorted(lidar_dir.glob('*.pcd'))
239 logger.info(f"Found {len(pcd_files)} LiDAR frames")
240
241 for pcd_file in pcd_files:
242 frame_points = load_pcd(pcd_file)
243 if frame_points is None or len(frame_points) == 0:
244 continue
245
246 # Get frame number from filename
247 try:
248 frame_num = int(pcd_file.stem)
249 except ValueError:
250 continue
251
252 # Get timestamp and interpolate pose
253 timestamp = lidar_timestamps.get(frame_num)
254 if timestamp is not None and poses:
255 pose = interpolate_pose(poses, timestamp)
256 if pose is not None:
257 # Transform points to world frame
258 frame_points = transform_points_to_world(frame_points, pose)
259
260 points.append(frame_points)
261
262 if points:

Callers 1

process_jobFunction · 0.85

Calls 5

load_posesFunction · 0.85
load_pcdFunction · 0.85
interpolate_poseFunction · 0.85
infoMethod · 0.45

Tested by

no test coverage detected