Load HiRoom format (indoor simulation, static). Layout: image/{idx}.jpg (RGB) depth/{idx}.png (uint16, raw / 655.35 -> meters) pose/{idx}.npy (4×4 world2cam; inverted to c2w here) cam_K.npy (3×3 shared in
(scene_dir: Path, frame_indices: list, z_far: float)
| 1343 | |
| 1344 | |
| 1345 | def _load_hiroom(scene_dir: Path, frame_indices: list, z_far: float): |
| 1346 | """Load HiRoom format (indoor simulation, static). |
| 1347 | |
| 1348 | Layout: |
| 1349 | image/{idx}.jpg (RGB) |
| 1350 | depth/{idx}.png (uint16, raw / 655.35 -> meters) |
| 1351 | pose/{idx}.npy (4×4 world2cam; inverted to c2w here) |
| 1352 | cam_K.npy (3×3 shared intrinsics) |
| 1353 | aliasing_mask/{idx}.png (uint8 0/255, >0 = invalid) |
| 1354 | """ |
| 1355 | image_dir = scene_dir / "image" |
| 1356 | depth_dir = scene_dir / "depth" |
| 1357 | pose_dir = scene_dir / "pose" |
| 1358 | mask_dir = scene_dir / "aliasing_mask" |
| 1359 | |
| 1360 | img_paths = sorted(image_dir.glob("*.jpg"), key=lambda p: int(p.stem)) |
| 1361 | K = np.load(str(scene_dir / "cam_K.npy")).astype(np.float32) |
| 1362 | |
| 1363 | HIROOM_DEPTH_SCALE = 65535.0 / 100.0 |
| 1364 | images, depths, extrinsics = [], [], [] |
| 1365 | for idx in frame_indices: |
| 1366 | if idx >= len(img_paths): |
| 1367 | continue |
| 1368 | img_path = img_paths[idx] |
| 1369 | stem = img_path.stem |
| 1370 | |
| 1371 | img = cv2.imread(str(img_path)) |
| 1372 | if img is not None: |
| 1373 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
| 1374 | else: |
| 1375 | img = np.zeros((1024, 1024, 3), dtype=np.uint8) |
| 1376 | |
| 1377 | d_raw = cv2.imread(str(depth_dir / f"{stem}.png"), cv2.IMREAD_UNCHANGED) |
| 1378 | if d_raw is not None: |
| 1379 | depth = d_raw.astype(np.float32) / HIROOM_DEPTH_SCALE |
| 1380 | depth[~np.isfinite(depth)] = 0 |
| 1381 | mask_path = mask_dir / f"{stem}.png" |
| 1382 | if mask_path.exists(): |
| 1383 | alias = cv2.imread(str(mask_path), cv2.IMREAD_UNCHANGED) |
| 1384 | if alias is not None: |
| 1385 | depth[alias > 0] = 0 |
| 1386 | depth[depth > z_far] = 0 |
| 1387 | else: |
| 1388 | depth = np.zeros((1024, 1024), dtype=np.float32) |
| 1389 | |
| 1390 | # Pose: w2c (4, 4) -> c2w (3, 4) |
| 1391 | w2c = np.load(str(pose_dir / f"{stem}.npy")).astype(np.float32) |
| 1392 | if w2c.shape == (3, 4): |
| 1393 | T = np.eye(4, dtype=np.float32) |
| 1394 | T[:3, :] = w2c |
| 1395 | w2c = T |
| 1396 | c2w = np.linalg.inv(w2c).astype(np.float32)[:3, :] |
| 1397 | |
| 1398 | images.append(img) |
| 1399 | depths.append(depth) |
| 1400 | extrinsics.append(c2w) |
| 1401 | |
| 1402 | return {"images": images, "depths": depths, "extrinsics": extrinsics, "K": K} |