"A benchmark rewards the sharpest map. A robot rewards the map that arrives on time, admits when it is guessing, and never tells the planner the wall is a doorway."
A Systems-Minded AI Agent
The Big Picture
The previous six sections built a monocular depth foundation model into a formidable component: zero-shot, dense, increasingly metric, sensor-promptable. This section is about the wiring around that component. A depth FM is almost never the product; it is one estimator inside a stack that also has odometry, a map, a planner, and often a real range sensor. Dropping it in raises questions no benchmark answers. Where does metric scale come from at run time? What is the latency budget, and does the model fit it after quantization? How do you keep depth stable across a video so a robot does not see the floor breathe? What does the model output when it is wrong, and how does the stack avoid trusting that output? And when should you not use a depth FM at all, because a $30 time-of-flight chip or a lidar already answers the question with a fraction of the risk? Answer these and the depth FM stops being a demo and becomes infrastructure.
This section is the integration capstone of the chapter, so it assumes the whole chapter behind it: affine-invariant versus metric prediction from Section 41.1 and Section 41.3, sensor prompting from Section 41.5, and the evaluation discipline of Section 41.6. It also reaches forward to the consumers of depth: bird's-eye-view and occupancy in Chapter 43, spatial mapping in Chapter 52, and the fusion machinery of Chapter 48.
What role does the depth FM play?
Decide the job before the model. A depth FM can sit in a stack in three distinct roles, and the right engineering follows from which one you pick. As a geometry primitive, it turns each frame into a point cloud that feeds detection, occupancy, or obstacle avoidance; here density and edge accuracy matter most, and scale must be sourced somewhere. As a prior or initializer, it seeds a downstream optimizer: dense monocular depth is a superb initialization for multi-view stereo or for the geometry term in a SLAM back end, which then refines it with true triangulation. As a gap-filler, it densifies a real but sparse sensor, covering the returns lidar misses on dark or specular surfaces. The role dictates the scale strategy. A primitive that drives a metric planner needs metric depth, so you either run a camera-agnostic metric model or prompt an affine model with a sparse sensor. A prior that will be triangulated later can stay relative, because the downstream optimizer supplies scale from motion. Confusing these is the most common integration mistake: teams demand metric perfection from a model whose output was going to be re-scaled anyway, or ship a relative model into a planner that silently assumed meters.
Key Insight
Scale is a system property, not a model property. A monocular image carries no absolute scale; the meters have to enter from somewhere with a physical reference: a calibrated stereo baseline, a range sensor, wheel odometry, a known camera height above a ground plane, or the intrinsics that a camera-agnostic model uses to reason about metric size. Ask "where do my meters come from?" at design time. If the honest answer is "the network guessed," you have a scale drift bug waiting for a lighting change or a new room to trigger it.
Latency, resolution, and the edge budget
A depth FM that runs at 2 frames per second on a workstation GPU is a research artifact, not a perception module. Real stacks impose a latency budget, and depth usually shares a compute envelope with detection, tracking, and planning. Three levers bring a large depth transformer into budget. First, resolution: inference cost scales with pixel count, and most planners need accurate geometry near obstacles more than crisp far detail, so running at a reduced resolution and upsampling with edge guidance often costs little accuracy where it matters. Second, backbone choice and distillation: model families ship small, base, and large variants, and a distilled small student trained from a large teacher recovers most of the accuracy at a fraction of the FLOPs. Third, quantization and compilation: converting to INT8 or FP16 and compiling to the target runtime (TensorRT, ONNX Runtime, Core ML, a mobile NPU) is the difference between a demo and an on-device feature, the toolkit of Chapter 59. Measure end to end: preprocessing and the sparse-alignment fit and the lift to a point cloud all consume the budget, and a model that is fast in isolation can miss the deadline once wrapped.
Video adds a second, subtler cost: temporal stability. Run a per-frame image model on a video and the depth flickers, because tiny input changes move the prediction and there is no constraint tying consecutive frames. A planner reading that stream sees phantom motion. Video depth models add temporal attention or a consistency loss so the geometry holds still when the scene does, and a lightweight alternative is to smooth per-frame depth through the pose from your odometry, warping the previous frame's depth into the current view and blending. Either way, temporal consistency is a hard requirement for control, not a nicety.
import numpy as np
def depth_fm_stack_step(rgb, sparse_z, sparse_mask, K, prev_depth=None,
flow_warp=None, conf_thresh=0.15):
"""One frame of a depth-FM perception step: predict, scale, gate, lift.
rgb : (H, W, 3) current camera frame
sparse_z : (H, W) metric returns from a range sensor (lidar / ToF)
sparse_mask: (H, W) bool, True where the range sensor has a return
K : (3, 3) camera intrinsics, for lifting depth to a point cloud
prev_depth : (H, W) previous metric depth, in the current view (pose-warped)
"""
disp = run_depth_fm(rgb) # affine-invariant inverse depth
a, b = fit_scale_shift(disp, sparse_z, sparse_mask) # meters from the sensor
depth = 1.0 / np.clip(a * disp + b, 1e-6, None) # dense metric depth
if prev_depth is not None: # temporal smoothing for control
depth = 0.7 * depth + 0.3 * prev_depth # blend warped previous frame
# Confidence from agreement with the sparse sensor at held-out returns.
resid = np.abs(depth[sparse_mask] - sparse_z[sparse_mask]) / sparse_z[sparse_mask]
frame_conf = float(np.median(resid))
trustworthy = frame_conf < conf_thresh # gate before the planner sees it
points = lift_to_pointcloud(depth, K) if trustworthy else None
return depth, points, trustworthy, frame_conf
run_depth_fm, fit_scale_shift, and lift_to_pointcloud stubs stand in for the model call, the least-squares alignment, and the intrinsics-based back-projection.Right Tool: from checkpoint to point cloud in a few lines
The heavy machinery of loading a depth FM, preprocessing, and running inference is a transformers pipeline call: pipeline("depth-estimation", model=...) replaces roughly 80 lines of manual weight loading, normalization, and tiling with two. For the lift to a point cloud, open3d.geometry.PointCloud.create_from_depth_image with your intrinsics turns the back-projection loop (per-pixel unprojection, masking invalid depth, assembling an array) into a single call, about 25 lines to one. What the library does not give you is the scale strategy, the gating, and the temporal smoothing above; those are yours to own because they are where the stack-specific risk lives.
Uncertainty, failure modes, and safety gating
A depth FM fails in ways that are quiet and geometry-shaped, which makes them dangerous. It hallucinates plausible depth on a blank wall, flattens a reflective floor into an abyss, reads a printed poster of a hallway as a real hallway, and collapses in scenes far from its training distribution. None of these announce themselves; the output looks like a confident, smooth depth map. So a depth FM must never feed a safety-critical planner as ground truth. Wrap it in three guards. First, a confidence signal: the cleanest source is disagreement with an independent measurement, the residual against held-out sparse returns in the code above, which is why keeping even a cheap range sensor in the loop pays off twice. Second, calibrated uncertainty: rather than trust a raw confidence, calibrate depth intervals so that a stated 90 percent interval contains the true depth 90 percent of the time, the conformal machinery of Chapter 18. Third, a fallback: when the gate trips, degrade to the raw range sensor, hold the last trusted map, or slow the system down, rather than acting on a hallucinated hallway. Adversarial framing matters too, because a printed scene or a projected pattern can spoof a monocular model in ways it cannot spoof a time-of-flight sensor, the threat model of Chapter 68.
Research Frontier: depth FMs as stack components in 2024 to 2026
The current frontier is exactly this integration question. Depth Anything V2 (Yang et al., 2024) ships small-to-large variants explicitly for the accuracy-versus-latency tradeoff a stack faces, and Video Depth Anything (2025) extends the family to temporally consistent long-video depth for streaming use. UniDepth (Piccinelli et al., 2024) and Metric3D v2 (Hu et al., 2024) target the scale-source problem directly by predicting metric depth from a single image plus intrinsics, removing the need for an external scale reference in some deployments. Prompt Depth Anything (Lin et al., 2024) closes the loop with a cheap phone lidar prompt for 4K metric depth on device. The open problems are honest per-pixel uncertainty that survives distribution shift, guaranteed temporal consistency under fast motion, and standardized on-robot latency reporting. Verify version numbers and metrics against the current releases before quoting them; this line moves fast.
Practical Example: a warehouse AMR that keeps a lidar honest
A robotics team builds an autonomous mobile robot (AMR) for warehouse aisles. It already carries a 2D safety lidar at knee height, certified for stopping distance, but that lidar is blind to overhanging shelf arms, hanging cables, and a pallet's top edge, all of which sit above its scan plane. Adding a 3D lidar blew the cost target. Instead they mounted a single forward camera and ran a distilled depth FM at reduced resolution, INT8, on the robot's existing NPU, inside a 30 millisecond budget shared with detection. The depth FM's job was scoped precisely: it is a geometry primitive for overhead-obstacle detection, not a replacement for the certified safety lidar. Metric scale came from the known camera height above the floor plane plus a handful of 2D lidar returns projected up as a scale prompt. Every frame, the stack cross-checked the depth map against the safety lidar where their fields of view overlapped; when the median disagreement spiked, on a glossy floor or a low-texture white wall, the gate tripped and the robot fell back to conservative speed on the certified lidar alone. The camera caught overhead hazards the lidar never could, and because the depth FM could only slow the robot and never override the certified stop, a depth hallucination degraded throughput but never safety.
When not to reach for a depth FM
The mark of maturity is knowing when the answer is no. If you need certified metric accuracy for a safety stop, a real range sensor with a physical measurement principle is the right tool, and a monocular estimate is at best a redundant cross-check, developed as a modality in Chapter 42. If the scene is textureless, transparent, or specular, the monocular prior degrades exactly where a time-of-flight or structured-light sensor still works, though even those struggle on glass. If a fixed, calibrated stereo rig already covers the field of view, its triangulated metric depth is cheaper to trust than a learned prior. And if the platform cannot spare the compute after quantization, a classical stereo or a cheap ToF module beats a depth FM that misses the deadline. The depth FM shines when a camera is already present, when dense geometry is needed on surfaces a sparse sensor misses, when the deployment spans domains no single dataset covered, and when the consumer of depth can tolerate a gated, uncertainty-aware estimate rather than a certified measurement. Treat it as one strong, cheap, general-purpose estimator among several, fused rather than trusted, and the stack gets the best of the foundation-model prior without inheriting its failure modes.
Exercise
Take a short indoor video with a phone that exposes its lidar or ToF depth (or any RGB-D clip). Build the per-frame step from the code above end to end: run a zero-shot depth FM, fit scale-and-shift to the sparse depth, and lift to a point cloud. Then measure three things across the clip. (a) Latency: profile each stage and report the end-to-end per-frame time, not just the model call. (b) Temporal stability: compute the frame-to-frame change in depth on a static patch of floor, with and without the pose-warped smoothing term, and report the reduction. (c) Gating: hand-label three frames where the depth is visibly wrong (a reflective or blank surface) and check whether your confidence residual actually trips the gate on those frames. Discuss any frame that looks correct but the gate flagged, and any that looks wrong but slipped through.
Self-Check
- Name the three roles a depth FM can play in a stack, and explain why the scale strategy differs between a geometry primitive and a prior for a SLAM back end.
- Why is a per-frame image depth model unsafe to feed directly to a controller, and what two mechanisms make its output usable?
- Give two concrete situations where the correct engineering decision is to not use a monocular depth FM, and say what you would use instead.
Lab 41
run a monocular depth foundation model zero-shot; fuse its output with a sparse depth sensor.
Bibliography
Depth foundation models and video depth
The workhorse depth FM whose small/base/large variants exist precisely for the accuracy-versus-latency tradeoff a deployed stack must navigate; the natural starting checkpoint for the lab.
Extends the family to temporally consistent streaming depth, addressing the flicker problem that makes per-frame models unsafe for control.
Metric scale and sensor prompting
Predicts metric depth from a single image with camera-agnostic reasoning, one clean answer to the "where do my meters come from" question at deployment time.
Zero-shot metric depth and surface normals via a canonical-camera transform, a strong metric primitive when no external scale reference is available.
Feeds a cheap phone lidar as a prompt for 4K metric depth on device, the sensor-prompted gap-filler role in production form.
Diffusion depth and deployment context
The diffusion depth prior underlying training-free guided completion; relevant when the stack can trade inference passes for adaptability to any sparse pattern.
The dense-prediction transformer backbone that most modern depth FMs inherit; understanding its cost model is what makes the resolution and distillation levers concrete.
What's Next
In Chapter 42, we turn to the real range sensor that has anchored every scale prompt and safety gate in this chapter: lidar. We build the point-cloud representations, sparse-convolution and transformer backbones, and detection and segmentation pipelines that let a machine reason directly in metric 3D, the measurement that a monocular depth FM approximates and a certified stack still depends on.