Load Tanks & Temples raw format data. Layout: images/*.jpg — RGB images depth/*.npz — float32 depth maps (key='arr_0') {scene_name}_COLMAP_SfM.log — extrinsics (4x4 per frame)
(scene_dir: Path, frame_indices: list, z_far: float, use_depth_mask: bool = True)
| 642 | |
| 643 | |
| 644 | def _load_tanks_raw(scene_dir: Path, frame_indices: list, z_far: float, use_depth_mask: bool = True): |
| 645 | """Load Tanks & Temples raw format data. |
| 646 | |
| 647 | Layout: |
| 648 | images/*.jpg — RGB images |
| 649 | depth/*.npz — float32 depth maps (key='arr_0') |
| 650 | {scene_name}_COLMAP_SfM.log — extrinsics (4x4 per frame) |
| 651 | """ |
| 652 | rgb_dir = scene_dir / "images" |
| 653 | depth_dir = scene_dir / "depth" |
| 654 | depth_mask_dir = scene_dir / "depth_mask" |
| 655 | |
| 656 | rgb_paths = sorted(rgb_dir.glob("*.jpg")) |
| 657 | depth_paths = sorted(depth_dir.glob("*.npz")) |
| 658 | depth_mask_paths = sorted(depth_mask_dir.glob("*.png")) if depth_mask_dir.exists() else [] |
| 659 | |
| 660 | # Read extrinsics from COLMAP log |
| 661 | log_files = list(scene_dir.glob("*_COLMAP_SfM.log")) |
| 662 | if not log_files: |
| 663 | raise FileNotFoundError(f"No *_COLMAP_SfM.log in {scene_dir}") |
| 664 | |
| 665 | all_extrinsics = [] |
| 666 | with open(str(log_files[0]), 'r') as f: |
| 667 | lines = f.readlines() |
| 668 | i = 0 |
| 669 | while i < len(lines): |
| 670 | line = lines[i].strip() |
| 671 | if not line: |
| 672 | i += 1 |
| 673 | continue |
| 674 | if len(line.split()) == 3: |
| 675 | i += 1 |
| 676 | mat_lines = lines[i:i + 4] |
| 677 | mat = np.array([[float(x) for x in l.split()] for l in mat_lines], dtype=np.float32) |
| 678 | all_extrinsics.append(mat) |
| 679 | i += 4 |
| 680 | else: |
| 681 | i += 1 |
| 682 | |
| 683 | # Estimate intrinsics from first image size |
| 684 | SCENE_IMAGE_SIZES = { |
| 685 | 'Barn': (1920, 1080), |
| 686 | 'Church': (1961, 1091), |
| 687 | 'Courthouse': (1962, 1091), |
| 688 | 'Ignatius': (1961, 1091), |
| 689 | } |
| 690 | scene_name = scene_dir.name |
| 691 | if scene_name in SCENE_IMAGE_SIZES: |
| 692 | W, H = SCENE_IMAGE_SIZES[scene_name] |
| 693 | elif rgb_paths: |
| 694 | img_tmp = cv2.imread(str(rgb_paths[0])) |
| 695 | H, W = img_tmp.shape[:2] |
| 696 | else: |
| 697 | W, H = 1920, 1080 |
| 698 | |
| 699 | fx = fy = 0.7 * W |
| 700 | K = np.array([[fx, 0, W / 2], [0, fy, H / 2], [0, 0, 1]], dtype=np.float32) |
| 701 |