# Depth Anything V2 and 3: relative vs metric depth

> Understand Depth Anything V2 and 3, relative versus metric depth, API output units, and a tested offline Python pinhole backprojection example.

OpenRobotics · December 1, 2026

**Depth Anything estimates scene geometry from RGB images, but its output is not automatically a distance in meters.** Depth Anything V2's general-purpose checkpoints produce relative depth. Depth Anything 3 adds any-view geometry, while its metric variants remain distinct checkpoints. For robotics, first identify the checkpoint, output convention, calibration, and actual backend; only then decide whether a value can become a 3D position.

In the OpenRobotics implementation reviewed on December 1, 2026, the V2 Small and DA3 Base adapters both return `relative_inverse`: larger values mean closer surfaces, not larger distances. The DA3 adapter uses one view and inverts its relative depth prediction. It does not expose every capability of upstream DA3. This guide explains that boundary and gives an executable, offline geometry fixture without downloading weights or making inference calls.

## What monocular depth estimation can infer

A single photograph has no absolute ruler. A small nearby object and a large distant object can project to the same pixels. Monocular depth estimation learns visual cues such as perspective, texture, occlusion, and familiar shapes to predict plausible geometry. Those learned priors can be useful even when absolute distance remains ambiguous.

An image encoder produces features, and a dense prediction head turns those features into a value at each pixel. A visualization may normalize those values into a bright foreground and dark background. That display operation loses numerical information: a colorful depth preview is not a measurement file, and identical colors in separate images need not describe identical distances.

For a robot, separate three questions: does the model preserve near/far ordering, does it recover useful surface shape, and does it recover calibrated distance? A model can answer the first two well and still fail the third. A plausible tabletop point cloud is not evidence that a commanded reach will stop above the table. [Physical AI explained](https://www.openrobotics.dev/blog/physical-ai) shows where depth sits among the other perception models a robot uses.

## Depth Anything V2: why the training recipe matters

The [Depth Anything V2 paper](https://arxiv.org/abs/2406.09414) describes three changes from V1: replacing labeled real training images with synthetic images, using a larger teacher, and training students through large-scale pseudo-labeled real images. Synthetic scenes provide cleaner geometric supervision; pseudo-labeled photographs help transfer that supervision back to real imagery.

The architecture remains a [DINOv2](https://www.openrobotics.dev/blog/dinov2-vs-dinov3) encoder with a DPT-style dense decoder. The [official V2 repository](https://github.com/DepthAnything/Depth-Anything-V2) notes that V2 decodes intermediate encoder features rather than the last four layers used in V1. The practical motivation is robust dense prediction and useful boundaries, not eliminating the ambiguity of monocular scale.

The upstream relative-depth family includes Small, Base, Large, and Giant configurations. Its licensing is checkpoint-specific: the README identifies Small as Apache-2.0 and Base, Large, and Giant as CC-BY-NC-4.0. Do not transfer Small's license to a larger checkpoint or assume that every derivative inherits the same permissions. Review the exact weights and code you intend to distribute.

V2 also has separately fine-tuned metric models. Their existence does not make the ordinary relative checkpoint metric. OpenRobotics' [Depth Anything V2](https://www.openrobotics.dev/models/bytedance/depth-anything-v2) adapter references `depth-anything/Depth-Anything-V2-Small-hf`, sets `unit = "relative_inverse"`, and does not select a metric fine-tune based on supplied camera intrinsics.

## Depth Anything 3: upstream geometry versus this adapter

The [Depth Anything 3 repository](https://github.com/ByteDance-Seed/Depth-Anything-3) describes a plain transformer and a unified depth-ray representation for geometry from arbitrary views. Its main series supports single-view and multi-view uses; the repository also distinguishes metric, monocular, and nested model series. A nested model combines any-view geometry with a metric estimator for scale.

Those are upstream capabilities, not interchangeable API promises. Here, [`bytedance/depth-anything-3`](https://www.openrobotics.dev/models/bytedance/depth-anything-3) selects `depth-anything/DA3-BASE`. The adapter constructs a tensor containing one image, reads the predicted depth, clamps it away from zero, and returns its reciprocal as relative inverse depth. It does not return camera poses, ray fields, or a multi-view reconstruction through this depth path.

Consequently, choosing DA3 instead of V2 does not remove the need to inspect `unit`. Nor does supplying multiple frames to a single-image adapter activate upstream multi-view inference. Choose an interface that explicitly implements the input and output you need, rather than deriving capabilities from the model family's name.

## Relative depth, inverse depth, and meters

The depth contract distinguishes three conventions:

- `relative_inverse` is unitless, with larger values closer to the camera. It is not a reciprocal distance with a known meter scale.
- `relative` is unitless, with larger values farther away. Unknown scale or offset still prevents direct metric backprojection.
- `m` denotes metric depth in meters. You must still establish whether the producer's depth convention and calibration match your geometry calculation.

For an affine inverse-depth calibration, a possible model is `1 / Z = a * q + b`, where `q` is the relative prediction and `Z` is reference depth in meters. Fitting `a` and `b` requires reliable, aligned reference measurements. Simply taking `1 / q` assumes a particular scale and zero offset that the relative model has not guaranteed.

Use multiple reference samples across the operating range, reject invalid references, and evaluate on held-out points. A fit that works on one scene may fail under a different focal length or visual domain. Never rename a relative map's `unit` to `m` merely because its values fall within a plausible distance range.

## The OpenRobotics depth request and response

The [depth API reference](https://www.openrobotics.dev/docs/api/depth) describes `POST /v1/depth`. The public request contains a `model` and an `image` encoded as base64 JPEG or PNG, optionally as a data URL. Optional `intrinsics` are `[fx, fy, cx, cy]` in pixels of the uploaded image. The worker contract adds the task envelope internally.

The depth payload contains `width`, `height`, `unit`, and row-major `data`: pixel `(u, v)` is `data[v * width + u]`. The shared Python adapter limits the longest output side to 256 pixels and adds `scale`. Read the returned dimensions rather than assuming they equal the original image size. Rounded dimensions can require separate horizontal and vertical scale factors.

The gateway validates the request, then routes through the configured worker pool. An enabled pool without a ready worker can return 503 while capacity starts. Where stand-ins are permitted and no worker candidate is configured, the integration can return deterministic simulated output; production can reject non-live models before this step. Inspect the response's `backend`. A simulated response can contain `unit: "m"`; that is a synthetic fixture, not evidence of measured metric depth or a running Depth Anything checkpoint. Catalog entries alone do not establish current availability, latency, pricing, or hardware suitability.

The shared contract also supports video frames, stereo inputs, and depth prompts for appropriate models. The V2 and DA3 adapters discussed here are monocular single-image adapters; they reject frames and unsupported depth prompts. Intrinsics alone do not cause these relative models to estimate metric scale.

## Worked Python fixture: valid pinhole backprojection

This is a **hand-authored metric fixture**, not Depth Anything output. It tests the downstream geometry that becomes valid only after you have trustworthy axial depth in meters. Save it as `depth_fixture.py` and run `python3 depth_fixture.py`. It uses only the Python standard library.

The input is a 3-by-2 row-major depth map and matching intrinsics. Integer pixel coordinates identify pixel centers. The camera optical frame is x right, y down, z forward. `timestamp_ns` is local capture metadata copied into the result; it is not a timestamp returned by the depth endpoint. Zero depth means invalid in this fixture.

```python
import json
import math

fixture = {
    "timestamp_ns": 1000000000,
    "frame_id": "camera_optical",
    "intrinsics": [2.0, 2.0, 1.0, 0.5],
    "depth": {
        "width": 3, "height": 2, "unit": "m",
        "data": [2.0, 2.0, 2.0, 4.0, 0.0, 4.0],
    },
}

def backproject(sample):
    depth = sample["depth"]
    if depth["unit"] != "m":
        raise ValueError("metric axial depth required")
    w, h = depth["width"], depth["height"]
    if type(w) is not int or type(h) is not int or min(w, h) < 1:
        raise ValueError("invalid dimensions")
    if len(depth["data"]) != w * h:
        raise ValueError("depth length mismatch")
    fx, fy, cx, cy = sample["intrinsics"]
    if not all(math.isfinite(k) for k in (fx, fy, cx, cy)):
        raise ValueError("nonfinite intrinsics")
    if fx <= 0 or fy <= 0:
        raise ValueError("positive focal lengths required")
    points = []
    for index, z in enumerate(depth["data"]):
        if not math.isfinite(z) or z <= 0:
            continue
        u, v = index % w, index // w
        points.append([(u - cx) * z / fx, (v - cy) * z / fy, z])
    return {
        "timestamp_ns": sample["timestamp_ns"],
        "frame_id": sample["frame_id"],
        "unit": "m", "points": points,
    }

result = backproject(fixture)
assert result["points"] == [
    [-1.0, -0.5, 2.0], [0.0, -0.5, 2.0], [1.0, -0.5, 2.0],
    [-2.0, 1.0, 4.0], [2.0, 1.0, 4.0],
]
for bad_depth in (
    {**fixture["depth"], "unit": "relative_inverse"},
    {**fixture["depth"], "data": [2.0]},
):
    try:
        backproject({**fixture, "depth": bad_depth})
    except ValueError:
        pass
    else:
        raise AssertionError("invalid fixture accepted")
print(json.dumps(result))
```

The tested output is:

```json
{"timestamp_ns": 1000000000, "frame_id": "camera_optical", "unit": "m", "points": [[-1.0, -0.5, 2.0], [0.0, -0.5, 2.0], [1.0, -0.5, 2.0], [-2.0, 1.0, 4.0], [2.0, 1.0, 4.0]]}
```

The pinhole equations are `X = (u - cx) * Z / fx`, `Y = (v - cy) * Z / fy`, and `Z = depth`. They assume an undistorted image and axial depth, not Euclidean range along the viewing ray. A range map requires conversion using the ray direction before applying these equations.

## Calibration, resizing, and synchronization

The fixture avoids resizing deliberately. In a real pipeline, adjust calibration to the depth grid using the exact image transform. For a half-pixel-center resize with factors `sx` and `sy`, use `fx' = sx * fx`, `fy' = sy * fy`, `cx' = sx * (cx + 0.5) - 0.5`, and the corresponding expression for `cy`. Cropping additionally changes the principal point. A different sampling convention needs its corresponding transform.

Backprojected points remain in the camera frame. Converting them into a robot base frame requires calibrated extrinsics and, for a moving wrist camera, the robot pose at capture time. Preserve the original capture timestamp alongside the response; network completion time is not capture time. A geometrically correct point at an old timestamp can still be unsafe to act on.

When combining depth with [SAM 2 masks](https://www.openrobotics.dev/blog/sam-2), align both grids before selecting object pixels. A mask may be at full image resolution while depth is reduced. Boundary pixels can mix foreground and background during resizing, so inspect interior samples and reject discontinuities rather than blindly averaging the whole bounding box.

## Failure checks and FAQ

### What is monocular depth estimation?

Monocular depth estimation predicts per-pixel depth from a single RGB image. A single photograph has no absolute ruler, so the model learns cues such as perspective, texture, occlusion and familiar shapes. It can preserve near/far ordering and surface shape well and still not recover calibrated distance in meters.

### Does Depth Anything output depth in meters?

Not by default. Depth Anything V2's general-purpose checkpoints produce relative depth, and the OpenRobotics V2 Small and DA3 Base adapters return `relative_inverse`, where larger values mean closer surfaces. Metric output requires a separately fine-tuned metric checkpoint or a calibration against reliable reference measurements.

### Why does the point cloud look inside out?

First check whether inverse depth was treated as distance. Then check row-major indexing, x/y order, and camera-axis signs. A left/right mirror often indicates a coordinate transform error; a globally incorrect scale can come from millimeters treated as meters or unchanged focal lengths after resizing.

### Can relative depth support navigation?

It can supply ordering or learned features, but it does not establish stopping distance. Test the complete perception-and-control system against independent measurements, including transparent surfaces, reflective objects, thin structures, and unfamiliar scenes. Do not use a monocular prediction as the sole safety boundary.

### What about Video Depth Anything and Prompt Depth Anything?

They address different inputs. [Video Depth Anything](https://www.openrobotics.dev/models/bytedance/video-depth-anything) targets temporal consistency across frames; [Prompt Depth Anything](https://www.openrobotics.dev/models/bytedance/prompt-depth-anything) uses metric depth guidance alongside RGB. Neither capability is activated by adding unsupported fields to V2. Consult the exact model interface and checkpoint documentation, including license terms, before changing the pipeline.

### Does this example measure model quality or speed?

No. It verifies indexing, unit rejection, invalid-sample handling, and pinhole arithmetic on known numbers. It does not load a model, establish a latency budget, validate predicted depth, or demonstrate robot compatibility. That separation makes the fixture useful: geometry bugs can be caught offline before any model evaluation begins.

Implementation references: the [depth wire contract](https://github.com/basilysf1709/openrobotics/blob/1bb6e18/packages/contracts/src/tasks.ts) defines units and output fields; the [perception gateway](https://github.com/basilysf1709/openrobotics/blob/1bb6e18/packages/gateway/src/endpoints/perception.ts) defines worker routing and stand-in output. These are source-level observations, not live deployment measurements.
