Skip to content

relative_depth

relative_depth #

The relative-depth file scalar; a loaded RelativeDepth is the file path.

RelativeDepth #

Bases: EXRScalar

A learned model's depth map in the model's own units, as 32-bit float OpenEXR.

Metric only up to an affine map in inverse depth, which is what separates it from a Depth: it becomes one once fitted to a measured reference. The R channel holds the model's depth values; an optional A channel holds the model's per-pixel confidence in [0, 1].

Analysis-only: produced by a recipe, never captured, so it has no platform mirror and no place in a schema.

Source code in capturegraph-recipes/capturegraph_recipes/types/geometry/relative_depth.py
class RelativeDepth(cg.EXRScalar, name="edu.cornell.relative_depth"):
    """A learned model's depth map in the model's own units, as 32-bit float OpenEXR.

    Metric only up to an affine map in inverse depth, which is what separates
    it from a ``Depth``: it becomes one once fitted to a measured reference.
    The ``R`` channel holds the model's depth values; an optional ``A`` channel
    holds the model's per-pixel confidence in ``[0, 1]``.

    Analysis-only: produced by a recipe, never captured, so it has no platform
    mirror and no place in a schema.
    """

    __slots__ = ()

    analysis_only = True

    @classmethod
    def of_arrays(cls, values: np.ndarray, confidence: np.ndarray | None = None) -> Self:
        """A fresh map of ``values`` (``H×W``) and optional ``confidence`` in the ambient workspace.

        Raises:
            NoWorkspace: If nothing provides a workspace.
        """
        return cls.of({"R": values} if confidence is None else {"R": values, "A": confidence})

    def to_array(self) -> np.ndarray:
        """The depth map as an ``H×W`` float array in the model's units.

        Raises:
            OSError: If the EXR carries no ``R`` channel.
        """
        planes = self.planes()
        if "R" not in planes:
            raise OSError(f"RelativeDepth EXR has no R channel: {self}")
        return planes["R"]

    def confidence(self) -> np.ndarray | None:
        """The per-pixel confidence as an ``H×W`` float array in ``[0, 1]``.

        ``None`` when the map carries no confidence channel.
        """
        return self.planes().get("A")

confidence() #

The per-pixel confidence as an H×W float array in [0, 1].

None when the map carries no confidence channel.

Source code in capturegraph-recipes/capturegraph_recipes/types/geometry/relative_depth.py
def confidence(self) -> np.ndarray | None:
    """The per-pixel confidence as an ``H×W`` float array in ``[0, 1]``.

    ``None`` when the map carries no confidence channel.
    """
    return self.planes().get("A")

of_arrays(values, confidence=None) classmethod #

A fresh map of values (H×W) and optional confidence in the ambient workspace.

Raises:

Type Description
NoWorkspace

If nothing provides a workspace.

Source code in capturegraph-recipes/capturegraph_recipes/types/geometry/relative_depth.py
@classmethod
def of_arrays(cls, values: np.ndarray, confidence: np.ndarray | None = None) -> Self:
    """A fresh map of ``values`` (``H×W``) and optional ``confidence`` in the ambient workspace.

    Raises:
        NoWorkspace: If nothing provides a workspace.
    """
    return cls.of({"R": values} if confidence is None else {"R": values, "A": confidence})

to_array() #

The depth map as an H×W float array in the model's units.

Raises:

Type Description
OSError

If the EXR carries no R channel.

Source code in capturegraph-recipes/capturegraph_recipes/types/geometry/relative_depth.py
def to_array(self) -> np.ndarray:
    """The depth map as an ``H×W`` float array in the model's units.

    Raises:
        OSError: If the EXR carries no ``R`` channel.
    """
    planes = self.planes()
    if "R" not in planes:
        raise OSError(f"RelativeDepth EXR has no R channel: {self}")
    return planes["R"]