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

Function get_scene_depth_viz

visualize_benchmark_web.py:1610–1629  ·  view source on GitHub ↗

Get colorized depth for a specific frame.

(scene_id: str, frame_idx: int, z_far: float = Query(10.0), depth_mask: bool = Query(True), conf_threshold: float = Query(0.0))

Source from the content-addressed store, hash-verified

1608
1609@app.get("/api/scene/{scene_id}/depth_viz/{frame_idx}")
1610def get_scene_depth_viz(scene_id: str, frame_idx: int, z_far: float = Query(10.0), depth_mask: bool = Query(True), conf_threshold: float = Query(0.0)):
1611 """Get colorized depth for a specific frame."""
1612 scene = _find_scene(scene_id)
1613 if scene is None:
1614 return Response(status_code=404)
1615
1616 data = _load_scene_data_raw(scene, z_far, use_depth_mask=depth_mask, conf_threshold=conf_threshold)
1617 if frame_idx >= len(data["depths"]):
1618 return Response(status_code=404)
1619
1620 depth = data["depths"][frame_idx]
1621 valid = depth > 0.01
1622 depth_norm = np.zeros_like(depth)
1623 if valid.any():
1624 depth_norm[valid] = np.clip(depth[valid] / z_far, 0, 1)
1625 colored = cv2.applyColorMap((depth_norm * 255).astype(np.uint8), cv2.COLORMAP_TURBO)
1626 colored[~valid] = 0
1627
1628 _, buf = cv2.imencode(".jpg", colored, [cv2.IMWRITE_JPEG_QUALITY, 85])
1629 return Response(content=buf.tobytes(), media_type="image/jpeg")
1630
1631
1632@app.get("/api/scene/{scene_id}/pcd")

Callers

nothing calls this directly

Calls 2

_find_sceneFunction · 0.85
_load_scene_data_rawFunction · 0.85

Tested by

no test coverage detected