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

Function _load_scene_data_raw

visualize_benchmark_web.py:126–212  ·  view source on GitHub ↗

Load a scene through BenchmarkDataset's current unified data pipeline. Current SpatialBenchmark layout: / / / /{images,depths,poses,intrinsics,...} This function adapts the BenchmarkDataset output to the older web-viewer return shape:

(scene: dict, z_far: float, use_depth_mask: bool = True, conf_threshold: float = 0.0)

Source from the content-addressed store, hash-verified

124
125
126def _load_scene_data_raw(scene: dict, z_far: float, use_depth_mask: bool = True, conf_threshold: float = 0.0):
127 """Load a scene through BenchmarkDataset's current unified data pipeline.
128
129 Current SpatialBenchmark layout:
130 <benchmark_root>/<density>/<dataset>/<scene_path>/{images,depths,poses,intrinsics,...}
131
132 This function adapts the BenchmarkDataset output to the older web-viewer
133 return shape: lists of RGB uint8 images, depth maps, c2w extrinsics, and
134 intrinsics. Dataset-specific path and depth decoding logic lives in
135 benchmark/datasets/data_readers.py.
136 """
137 if _benchmark_dataset is None:
138 raise RuntimeError("BenchmarkDataset is not initialized")
139
140 dataset = scene["source_dataset"]
141 scene_id = scene["scene_id"]
142 ds_idx = _scene_to_dataset_idx.get(scene_id)
143 if ds_idx is None:
144 raise KeyError(f"Scene {scene_id!r} not found in BenchmarkDataset")
145
146 reader = _benchmark_dataset._readers.get(dataset)
147 if reader is None:
148 raise ValueError(f"No reader for dataset {dataset!r}")
149
150 # Endpoint controls are applied by temporarily overriding the reader settings
151 # before BenchmarkDataset calls reader.read_scene().
152 had_z_far = 'DEFAULT_Z_FAR' in reader.__dict__
153 orig_z_far = getattr(reader, 'DEFAULT_Z_FAR', None)
154 had_depth_masks = '_USE_DEPTH_MASKS' in reader.__dict__
155 orig_depth_masks = getattr(reader, '_USE_DEPTH_MASKS', True)
156 had_aliasing_masks = '_USE_ALIASING_MASKS' in reader.__dict__
157 orig_aliasing_masks = getattr(reader, '_USE_ALIASING_MASKS', True)
158 had_conf = 'conf_threshold' in reader.__dict__
159 orig_conf = getattr(reader, 'conf_threshold', None)
160
161 try:
162 reader.DEFAULT_Z_FAR = float(z_far)
163 if not use_depth_mask:
164 reader._USE_DEPTH_MASKS = False
165 reader._USE_ALIASING_MASKS = False
166 if hasattr(reader, 'conf_threshold'):
167 reader.conf_threshold = float(conf_threshold)
168
169 loaded = _benchmark_dataset[ds_idx]
170 finally:
171 if had_z_far:
172 reader.DEFAULT_Z_FAR = orig_z_far
173 elif 'DEFAULT_Z_FAR' in reader.__dict__:
174 delattr(reader, 'DEFAULT_Z_FAR')
175
176 if had_depth_masks:
177 reader._USE_DEPTH_MASKS = orig_depth_masks
178 elif '_USE_DEPTH_MASKS' in reader.__dict__:
179 delattr(reader, '_USE_DEPTH_MASKS')
180
181 if had_aliasing_masks:
182 reader._USE_ALIASING_MASKS = orig_aliasing_masks
183 elif '_USE_ALIASING_MASKS' in reader.__dict__:

Callers 5

get_scene_rgbFunction · 0.85
get_scene_depth_vizFunction · 0.85
get_scene_pcdFunction · 0.85
get_scene_camerasFunction · 0.85
export_scene_glbFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected