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

Function _load_lingbot

visualize_benchmark_web.py:1192–1250  ·  view source on GitHub ↗

Load Lingbot single-frame data. Layout: rgb.jpg — RGB image depth.png — uint16 PNG depth (mm) intrinsic.txt — 3x3 intrinsic matrix in plain text depth_mask.png — binary mask from flying-point cleaning (optional) sky_mask.png — binary sky ma

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

Source from the content-addressed store, hash-verified

1190
1191
1192def _load_lingbot(scene_dir: Path, frame_indices: list, z_far: float, use_depth_mask: bool = True):
1193 """Load Lingbot single-frame data.
1194
1195 Layout:
1196 rgb.jpg — RGB image
1197 depth.png — uint16 PNG depth (mm)
1198 intrinsic.txt — 3x3 intrinsic matrix in plain text
1199 depth_mask.png — binary mask from flying-point cleaning (optional)
1200 sky_mask.png — binary sky mask for outdoor scenes (optional)
1201 """
1202 # Intrinsics from txt
1203 K = np.loadtxt(str(scene_dir / "intrinsic.txt")).astype(np.float32)
1204
1205 # Load masks if available
1206 depth_mask_path = scene_dir / "depth_mask.png"
1207 sky_mask_path = scene_dir / "sky_mask.png"
1208
1209 images, depths, extrinsics = [], [], []
1210 for idx in frame_indices:
1211 if idx != 0:
1212 continue # single-frame dataset, only index 0
1213
1214 # RGB
1215 img = cv2.imread(str(scene_dir / "rgb.jpg"))
1216 if img is not None:
1217 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
1218 else:
1219 img = np.zeros((720, 1280, 3), dtype=np.uint8)
1220
1221 # Depth (uint16 mm -> metres)
1222 d_raw = cv2.imread(str(scene_dir / "depth.png"), cv2.IMREAD_UNCHANGED)
1223 if d_raw is not None:
1224 depth = d_raw.astype(np.float32) / 1000.0
1225 depth[~np.isfinite(depth)] = 0
1226 # Apply depth_mask (flying-point removal) + sky_mask
1227 if use_depth_mask:
1228 if depth_mask_path.exists():
1229 mask = cv2.imread(str(depth_mask_path), cv2.IMREAD_UNCHANGED)
1230 if mask is not None:
1231 depth[mask == 0] = 0
1232 if sky_mask_path.exists():
1233 sky_mask = cv2.imread(str(sky_mask_path), cv2.IMREAD_UNCHANGED)
1234 if sky_mask is not None:
1235 depth[sky_mask > 0] = 0
1236 depth[depth > z_far] = 0
1237 else:
1238 depth = np.zeros((720, 1280), dtype=np.float32)
1239
1240 # Identity pose (single frame, no extrinsics)
1241 pose = np.eye(3, 4, dtype=np.float32)
1242
1243 images.append(img)
1244 depths.append(depth)
1245 extrinsics.append(pose)
1246
1247 return {
1248 "images": images, "depths": depths,
1249 "extrinsics": extrinsics, "K": K,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected