MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / _load_adt

Function _load_adt

visualize_benchmark_web.py:388–450  ·  view source on GitHub ↗

Load ADT (Aria Digital Twin) format data. Layout: rgb_rectified/*.png — timestamp-named RGB images depth_rectified/*.png — uint16 PNG depth (mm), timestamp-named depth_mask/*.png — optional binary mask from depth cleaning intrinsic.npy — 3x

(scene_dir: Path, frame_indices: list, z_far: float, use_depth_mask: bool = True)

Source from the content-addressed store, hash-verified

386
387
388def _load_adt(scene_dir: Path, frame_indices: list, z_far: float, use_depth_mask: bool = True):
389 """Load ADT (Aria Digital Twin) format data.
390
391 Layout:
392 rgb_rectified/*.png — timestamp-named RGB images
393 depth_rectified/*.png — uint16 PNG depth (mm), timestamp-named
394 depth_mask/*.png — optional binary mask from depth cleaning
395 intrinsic.npy — 3x3 camera intrinsic matrix
396 camera_to_world/*.npy — per-frame 3x4 cam-to-world poses
397 """
398 rgb_dir = scene_dir / "rgb_rectified"
399 depth_dir = scene_dir / "depth_rectified"
400 depth_mask_dir = scene_dir / "depth_mask"
401 pose_dir = scene_dir / "camera_to_world"
402
403 rgb_paths = sorted(rgb_dir.glob("*.png"))
404 depth_paths = sorted(depth_dir.glob("*.png"))
405 pose_paths = sorted(pose_dir.glob("*.npy"))
406 depth_mask_paths = sorted(depth_mask_dir.glob("*.png")) if depth_mask_dir.exists() else []
407
408 # Intrinsics
409 K_path = scene_dir / "intrinsic.npy"
410 K = np.load(str(K_path)).astype(np.float32) if K_path.exists() else np.eye(3, dtype=np.float32)
411
412 images, depths, extrinsics = [], [], []
413 for idx in frame_indices:
414 if idx >= len(rgb_paths) or idx >= len(depth_paths) or idx >= len(pose_paths):
415 continue
416
417 # RGB
418 img = cv2.imread(str(rgb_paths[idx]))
419 if img is not None:
420 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
421 else:
422 img = np.zeros((512, 512, 3), dtype=np.uint8)
423
424 # Depth (uint16 mm -> metres)
425 d_raw = cv2.imread(str(depth_paths[idx]), cv2.IMREAD_UNCHANGED)
426 if d_raw is not None:
427 depth = d_raw.astype(np.float32) / 1000.0
428 depth[~np.isfinite(depth)] = 0
429 # Apply depth mask if available
430 if use_depth_mask and depth_mask_paths and idx < len(depth_mask_paths):
431 mask = cv2.imread(str(depth_mask_paths[idx]), cv2.IMREAD_UNCHANGED)
432 if mask is not None:
433 depth[mask == 0] = 0
434 depth[depth > z_far] = 0
435 else:
436 depth = np.zeros((512, 512), dtype=np.float32)
437
438 # Pose (3x4 cam-to-world)
439 pose = np.load(str(pose_paths[idx])).astype(np.float32)
440 if pose.shape == (4, 4):
441 pose = pose[:3, :]
442
443 images.append(img)
444 depths.append(depth)
445 extrinsics.append(pose)

Callers

nothing calls this directly

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected