Skip to content
AI360Xpert
Beta

Monocular Depth from One Image

One photo has no baseline, yet size, overlap, and haze hint at distance. Monocular depth learns those cues to guess meters from a single view.

One image yields relative disparity that median alignment turns into metric depth
One image yields relative disparity that median alignment turns into metric depth

Why Does This Exist?

Stereo rigs cost money and calibration, and most web photos have one view only. Monocular depth exists to guess geometry where no baseline exists, using learned priors over size and layout. It powers background blur, single-image 3D photos, and scale-free pretraining for Depth Anything style foundation models.

This page covers the single-image formulation and its scale handling. The family map is depth estimation; metric stereo is stereo depth estimation; sparse-guided densification is depth completion.

Think of It Like This

An artist shading depth from memory

An artist draws a road shrinking to a dot and shades distant hills pale blue without measuring anything. Cars get small with distance because memory says so, not because a ruler confirmed it.

Nets are the artist and training sets are the memory. The analogy stops at novelty: artists extrapolate to alien scenes while nets collapse outside their training mix.

How It Actually Works

The net maps II to inverse depth or disparity d^\hat{d} trained with a scale-and-shift-invariant loss: predictions and truth are median-aligned via ss and tt that minimize ∣ sd^+t−d ∣|\,s \hat{d} + t - d\,| before scoring. Metric variants add camera intrinsics or a scale head to output ZZ directly but generalize worse across cameras. At test time, one sparse lidar return or known object height fixes ss and turns the relative map metric. Ordinal cues such as occlusion edges and vanishing points emerge in middle layers.

Worked numbers

Truth depths 2.02.0, 4.04.0, 8.08.0 m with raw outputs 0.50.5, 1.01.0, 2.02.0 (perfect shape, wrong scale). Median ratio s=4.0s = 4.0 maps outputs to 2.02.0, 4.04.0, 8.08.0 m exactly, AbsRel 0.00.0. Adding 55 percent noise to outputs gives predictions 2.12.1, 3.93.9, 8.28.2 m with mean AbsRel (0.05+0.025+0.025)/3≈0.033(0.05 + 0.025 + 0.025)/3 \approx 0.033.

Code

def median_scale(pred: list[float], gt: list[float]) -> float:    ratios = sorted(g / p for g, p in zip(gt, pred))  # robust scale from pairs    return ratios[len(ratios) // 2]

print(median_scale([0.5, 1.0, 2.0], [2.0, 4.0, 8.0]))  # -> 4.0

Watch Out For

Deploying relative depth as meters

Relative maps look right in colormap but their numbers are arbitrary; feeding them to planning yields confident wrong distances. The symptom is perfect-looking previews with 3030 percent scale error. Always attach a scale source such as sparse lidar, stereo, or known height before acting.

The Quick Version

  • Monocular depth predicts shape from one image using learned size and layout cues.
  • Outputs are disparity up to unknown scale and shift, not meters.
  • Median alignment against sparse truth recovers metric scale.
  • Scale-invariant losses train across mixed cameras without calibration.
  • Typical indoor AbsRel after alignment sits near 0.100.10.
  • Novel scenes and mirrors break the learned priors first.