### BlendedMVS Directory Structure Example Source: https://context7.com/yoyo000/blendedmvs/llms.txt This illustrates the expected directory layout after extracting the BlendedMVS dataset. Each scene is organized by its Project ID (PID) and contains blended images, camera parameters, and depth maps. ```tree DATA_ROOT ├── BlendedMVG_list.txt # 502 scene IDs for the full BlendedMVG superset ├── BlendedMVS_list.txt # 113 scene IDs for the core BlendedMVS subset ├── BlendedMVS+_list.txt # scene IDs for the BlendedMVS+ subset ├── BlendedMVS++_list.txt # scene IDs for the BlendedMVS++ subset ├── 5bfe5ae0fe0ea555e6a969ca/ # example scene directory (PID) │ ├── blended_images/ │ │ ├── 00000000.jpg # rendered + blended color image │ │ ├── 00000000_masked.jpg # same image with foreground mask applied │ │ ├── 00000001.jpg │ │ ├── 00000001_masked.jpg │ │ └── ... │ ├── cams/ │ │ ├── pair.txt # view selection: reference → source image pairs │ │ ├── 00000000_cam.txt # camera intrinsics + extrinsics for view 0 │ │ ├── 00000001_cam.txt │ │ └── ... │ └── rendered_depth_maps/ │ ├── 00000000.pfm # ground-truth depth map in PFM format │ ├── 00000001.pfm │ └── ... ├── 58eaf1513353456af3a1682a/ └── ... # up to PID501 for BlendedMVG ``` -------------------------------- ### Download BlendedMVS (Low-Res) Source: https://context7.com/yoyo000/blendedmvs/llms.txt Use this command to download the original BlendedMVS subset (low-resolution). Unzip the archive into your desired data root directory. ```bash # Download BlendedMVS low-resolution set (768x576, 27.5 GB) wget https://github.com/YoYo000/BlendedMVS/releases/download/v1.0.0/BlendedMVS.zip # Unzip into your data root unzip BlendedMVS.zip -d /path/to/DATA_ROOT ``` -------------------------------- ### Download BlendedMVS++ (Split Archives) Source: https://context7.com/yoyo000/blendedmvs/llms.txt This script downloads all 42 split archive parts for BlendedMVS++ and the final zip descriptor. Ensure all parts are downloaded before extraction using p7zip. ```bash #!/bin/bash BASE_URL="https://github.com/YoYo000/BlendedMVS/releases/download/v1.0.2" # Download split parts BlendedMVS2.z01 through BlendedMVS2.z42 for i in $(seq -w 1 42); do FILE="BlendedMVS2.z$i" echo "Downloading $FILE..." wget -c "${BASE_URL}/${FILE}" done # Download the final zip descriptor wget -c "${BASE_URL}/BlendedMVS2.zip" echo "All parts downloaded. Extracting..." 7z x BlendedMVS2.zip -o/path/to/DATA_ROOT ``` -------------------------------- ### Download BlendedMVS Dataset Source: https://github.com/yoyo000/blendedmvs/blob/master/README.md Use this command to download the main BlendedMVS dataset archive. ```bash wget https://github.com/YoYo000/BlendedMVS/releases/download/v1.0.0/BlendedMVS.zip ``` -------------------------------- ### Download BlendedMVS+ (Split Archives) Source: https://context7.com/yoyo000/blendedmvs/llms.txt This script downloads all 42 split archive parts for BlendedMVS+ and the final zip descriptor. Ensure all parts are downloaded before extraction using p7zip. ```bash #!/bin/bash BASE_URL="https://github.com/YoYo000/BlendedMVS/releases/download/v1.0.1" # Download split parts BlendedMVS1.z01 through BlendedMVS1.z42 for i in $(seq -w 1 42); do FILE="BlendedMVS1.z$i" echo "Downloading $FILE..." wget -c "${BASE_URL}/${FILE}" done # Download the final zip descriptor wget -c "${BASE_URL}/BlendedMVS1.zip" echo "All parts downloaded. Extracting..." # On Linux: use p7zip 7z x BlendedMVS1.zip -o/path/to/DATA_ROOT ``` -------------------------------- ### Download BlendedMVS+ Dataset Source: https://github.com/yoyo000/blendedmvs/blob/master/README.md This script downloads the BlendedMVS+ dataset, which is split into multiple .z files and a final .zip file. It uses wget with the -c option to allow resuming interrupted downloads. ```bash #!/bin/bash # Base URL BASE_URL="https://github.com/YoYo000/BlendedMVS/releases/download/v1.0.1" # Download split files BlendedMVS1.z01 to BlendedMVS1.z42 for i in $(seq -w 1 42); do FILE="BlendedMVS1.z$i" echo "Downloading $FILE..." wget -c "${BASE_URL}/${FILE}" done # Download the final .zip descriptor ZIP_FILE="BlendedMVS1.zip" echo "Downloading $ZIP_FILE..." wget -c "${BASE_URL}/${ZIP_FILE}" echo "All files downloaded." ``` -------------------------------- ### Parse BlendedMVS Pair File (Python) Source: https://context7.com/yoyo000/blendedmvs/llms.txt Parses a pair.txt file to create a dictionary mapping reference view indices to lists of source view indices and their associated scores. The source views are pre-sorted by score in descending order. ```python def parse_pair_file(pair_path): """ Parse pair.txt into a dict mapping reference view index to a list of (source_idx, score) tuples, sorted by score descending. """ pairs = {} with open(pair_path, 'r') as f: num_views = int(f.readline().strip()) for _ in range(num_views): ref_idx = int(f.readline().strip()) tokens = f.readline().strip().split() num_src = int(tokens[0]) sources = [] for i in range(num_src): src_idx = int(tokens[1 + i * 2]) score = float(tokens[2 + i * 2]) sources.append((src_idx, score)) pairs[ref_idx] = sources # already sorted by score return pairs # Example usage pairs = parse_pair_file('5bfe5ae0fe0ea555e6a969ca/cams/pair.txt') ref = 0 print(f"Reference view {ref} → source views: {pairs[ref][:5]}") # Reference view 0 → source views: [(1, 2.345), (2, 2.101), (3, 1.987), (4, 1.876), (5, 1.654)] ``` -------------------------------- ### Download BlendedMVS++ Dataset Source: https://github.com/yoyo000/blendedmvs/blob/master/README.md This script downloads the BlendedMVS++ dataset, which is also split into multiple .z files and a final .zip file. It supports resuming interrupted downloads using wget -c. ```bash #!/bin/bash # Base URL BASE_URL="https://github.com/YoYo000/BlendedMVS/releases/download/v1.0.2" # Download split files BlendedMVS2.z01 to BlendedMVS2.z42 for i in $(seq -w 1 42); do FILE="BlendedMVS2.z$i" echo "Downloading $FILE..." wget -c "${BASE_URL}/${FILE}" done # Download the final .zip descriptor ZIP_FILE="BlendedMVS2.zip" echo "Downloading $ZIP_FILE..." wget -c "${BASE_URL}/${ZIP_FILE}" echo "All files downloaded." ``` -------------------------------- ### Parse BlendedMVS Camera File (Python) Source: https://context7.com/yoyo000/blendedmvs/llms.txt Parses a *_cam.txt file to extract extrinsic and intrinsic camera matrices, along with depth range parameters. Ensure the file path is correct. ```python import numpy as np def parse_cam_file(cam_path): """Parse a BlendedMVS *_cam.txt file into extrinsic, intrinsic, and depth range.""" with open(cam_path, 'r') as f: lines = [l.strip() for l in f if l.strip()] # Extrinsic matrix (4x4): lines 1–4 after 'extrinsic' header extrinsic = np.array([ list(map(float, lines[1].split())) list(map(float, lines[2].split())) list(map(float, lines[3].split())) list(map(float, lines[4].split())) ]) # shape (4, 4) # Intrinsic matrix (3x3): lines after 'intrinsic' header intrinsic = np.array([ list(map(float, lines[6].split())) list(map(float, lines[7].split())) list(map(float, lines[8].split())) ]) # shape (3, 3) # Depth range depth_params = lines[9].split() depth_min = float(depth_params[0]) depth_max = float(depth_params[1]) # Guard against degenerate depth values (documented edge case) if depth_min <= 0 or depth_max <= 0: print(f"Warning: non-positive depth range in {cam_path}: [{depth_min}, {depth_max}]") return extrinsic, intrinsic, depth_min, depth_max # Example usage extrinsic, intrinsic, d_min, d_max = parse_cam_file('5bfe5ae0fe0ea555e6a969ca/cams/00000000_cam.txt') print("Extrinsic:\n", extrinsic) print("Intrinsic:\n", intrinsic) print(f"Depth range: [{d_min}, {d_max}]") ``` -------------------------------- ### Load BlendedMVS Scene List Source: https://context7.com/yoyo000/blendedmvs/llms.txt Loads scene IDs from a text file and returns valid scene paths within the specified data root. It warns if scene directories are not found. ```python import os def load_scene_list(list_path, data_root): """ Load a BlendedMVS scene list and return valid scene paths. Skips IDs whose directories do not exist under data_root. """ scenes = [] with open(list_path, 'r') as f: for line in f: pid = line.strip() if not pid: continue scene_dir = os.path.join(data_root, pid) if os.path.isdir(scene_dir): scenes.append(scene_dir) else: print(f"Warning: scene directory not found: {scene_dir}") return scenes DATA_ROOT = '/path/to/DATA_ROOT' # Load the core BlendedMVS training split (113 scenes) train_scenes = load_scene_list('project_lists/BlendedMVS_training.txt', DATA_ROOT) # Load the validation split (7 scenes) val_scenes = load_scene_list('project_lists/validation_list.txt', DATA_ROOT) print(f"Training scenes: {len(train_scenes)}") # up to 113 print(f"Validation scenes: {len(val_scenes)}") # 7 # Example: iterate over all images in training scenes for scene in train_scenes[:2]: img_dir = os.path.join(scene, 'blended_images') images = sorted(f for f in os.listdir(img_dir) if f.endswith('.jpg') and '_masked' not in f) print(f"{os.path.basename(scene)}: {len(images)} images") ``` -------------------------------- ### PyTorch Dataset for BlendedMVS Source: https://context7.com/yoyo000/blendedmvs/llms.txt A PyTorch Dataset that loads reference images, source images, camera parameters, and depth maps for MVS training. It requires helper functions like `parse_pair_file`, `read_pfm`, and `parse_cam_file` to be defined elsewhere. ```python import os, cv2, numpy as np from torch.utils.data import Dataset, DataLoader class BlendedMVSDataset(Dataset): def __init__(self, list_path, data_root, num_src=4, img_wh=(768, 576)): self.data_root = data_root self.num_src = num_src self.img_wh = img_wh self.metas = [] with open(list_path) as f: scene_ids = [l.strip() for l in f if l.strip()] for sid in scene_ids: scene_dir = os.path.join(data_root, sid) pair_path = os.path.join(scene_dir, 'cams', 'pair.txt') if not os.path.exists(pair_path): continue pairs = parse_pair_file(pair_path) # reuse function defined above for ref_idx, sources in pairs.items(): src_indices = [s[0] for s in sources[:num_src]] if len(src_indices) < num_src: continue # skip if not enough source views self.metas.append((scene_dir, ref_idx, src_indices)) def __len__(self): return len(self.metas) def __getitem__(self, idx): scene_dir, ref_idx, src_indices = self.metas[idx] def load_img(i): path = os.path.join(scene_dir, 'blended_images', f'{i:08d}.jpg') img = cv2.imread(path) img = cv2.resize(img, self.img_wh) return img.astype(np.float32) / 255.0 # normalize to [0, 1] ref_img = load_img(ref_idx) src_imgs = [load_img(i) for i in src_indices] # Load reference depth map depth_path = os.path.join(scene_dir, 'rendered_depth_maps', f'{ref_idx:08d}.pfm') depth, _ = read_pfm(depth_path) # reuse function defined above depth = cv2.resize(depth, self.img_wh, interpolation=cv2.INTER_NEAREST) # Load cameras ref_ext, ref_int, d_min, d_max = parse_cam_file( os.path.join(scene_dir, 'cams', f'{ref_idx:08d}_cam.txt')) return { 'ref_img': ref_img, # (H, W, 3) 'src_imgs': src_imgs, # list of (H, W, 3) 'ref_extrinsic': ref_ext, # (4, 4) 'ref_intrinsic': ref_int, # (3, 3) 'depth': depth, # (H, W) 'depth_min': d_min, 'depth_max': d_max, } # Usage dataset = BlendedMVSDataset( list_path='project_lists/BlendedMVS_training.txt', data_root='/path/to/DATA_ROOT', num_src=4, ) loader = DataLoader(dataset, batch_size=2, shuffle=True, num_workers=4) sample = next(iter(loader)) print("Batch ref_img shape:", sample['ref_img'].shape) # (2, 576, 768, 3) print("Depth shape:", sample['depth'].shape) # (2, 576, 768) ``` -------------------------------- ### Read PFM Depth Map (Python) Source: https://context7.com/yoyo000/blendedmvs/llms.txt Reads a depth map from a Portable Float Map (.pfm) file. Returns the depth data as a NumPy array and the scale factor. Handles both color and grayscale PFM formats. ```python import numpy as np import re, sys def read_pfm(filename): """Read a PFM depth map. Returns (data: np.ndarray, scale: float).""" with open(filename, 'rb') as f: header = f.readline().decode('utf-8').rstrip() if header == 'PF': color = True elif header == 'Pf': color = False else: raise ValueError(f"Not a PFM file: {filename}") dims = f.readline().decode('utf-8').strip() width, height = map(int, dims.split()) scale = float(f.readline().decode('utf-8').strip()) endian = '<' if scale < 0 else '>' scale = abs(scale) data = np.frombuffer(f.read(), endian + 'f') shape = (height, width, 3) if color else (height, width) data = np.reshape(data, shape) data = np.flipud(data) # PFM is stored bottom-to-top return data, scale # Example: load and inspect a depth map depth, scale = read_pfm('5bfe5ae0fe0ea555e6a969ca/rendered_depth_maps/00000000.pfm') print(f"Depth map shape: {depth.shape}") # e.g. (576, 768) print(f"Depth range: [{depth.min():.3f}, {depth.max():.3f}]") # Guard against empty depth maps (documented edge case) if depth.max() == 0: print("Warning: empty depth map — the mesh model may be incomplete for this view.") ``` -------------------------------- ### BibTeX Citation for BlendedMVS Source: https://context7.com/yoyo000/blendedmvs/llms.txt Use this BibTeX entry when publishing work that utilizes the BlendedMVS or BlendedMVG dataset. ```bibtex @article{yao2020blendedmvs, title={BlendedMVS: A Large-scale Dataset for Generalized Multi-view Stereo Networks}, author={Yao, Yao and Luo, Zixin and Li, Shiwei and Zhang, Jingyang and Ren, Yufan and Zhou, Lei and Fang, Tian and Quan, Long}, journal={Computer Vision and Pattern Recognition (CVPR)}, year={2020} } ``` -------------------------------- ### BlendedMVS Dataset Directory Structure Source: https://github.com/yoyo000/blendedmvs/blob/master/README.md This outlines the expected directory structure for the BlendedMVS dataset, adhering to the MVSNet input format. Ensure your dataset is organized similarly after downloading. ```text DATA_ROOT ├── BlendedMVG_list.txt ├── BlendedMVS_list.txt ├── BlendedMVS+_list.txt ├── BlendedMVS++_list.txt ├── ... ├── PID0 │  ├── blended_images │  │ ├── 00000000.jpg │  │ ├── 00000000_masked.jpg │  │ ├── 00000001.jpg │  │ ├── 00000001_masked.jpg │  │ └── ... │  ├── cams │  │   ├── pair.txt │  │   ├── 00000000_cam.txt │  │   ├── 00000001_cam.txt │  │   └── ... │  └── rendered_depth_maps │       ├── 00000000.pfm │     ├── 00000001.pfm │     └── ... ├── PID1 ├── ... └── PID501 ``` -------------------------------- ### BlendedMVS Citation Source: https://github.com/yoyo000/blendedmvs/blob/master/README.md This is the citation information for the BlendedMVS paper, to be used when referencing the dataset in academic work. ```bibtex @article{yao2020blendedmvs, title={BlendedMVS: A Large-scale Dataset for Generalized Multi-view Stereo Networks}, author={Yao, Yao and Luo, Zixin and Li, Shiwei and Zhang, Jingyang and Ren, Yufan and Zhou, Lei and Fang, Tian and Quan, Long}, journal={Computer Vision and Pattern Recognition (CVPR)}, year={2020} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.