roboflow/supervision · error · ValueError
Resolution width and height are required for moving…
Error message
Resolution width and height are required for moving segmentation detections. This should be the same as (width, height) of image shape.
What it means
Raised inside move_detections (used by InferenceSlicer to shift slice-local detections back into full-image coordinates) when the detections carry masks but resolution_wh is None. Masks are stored as full-resolution boolean arrays; moving them requires cropping/padding to the real image bounds, which is only possible when the target resolution is known.
Solutions
- Pass resolution_wh=(width, height) matching the image shape, e.g. from get_image_resolution_wh(image) or image.shape[1::-1].
- If you use InferenceSlicer normally, update supervision — the public path supplies resolution_wh; this error on the public API path indicates a version where that wiring was incomplete.
- For mask-less pipelines the parameter may stay None; drop masks (detections_without_masks) only if you truly do not need them.
Example fix
# before move_detections(detections=det, offset=np.array([100, 50]), resolution_wh=None) # ValueError when det.mask is set # after h, w = frame.shape[:2] move_detections(detections=det, offset=np.array([100, 50]), resolution_wh=(w, h))
Defensive patterns
Strategy: validation
Validate before calling
import numpy as np
def safe_move(detections, offset, frame=None):
resolution_wh = None
if detections.mask is not None and frame is not None:
h, w = frame.shape[:2]
resolution_wh = (w, h)
return move_detections(detections=detections, offset=offset, resolution_wh=resolution_wh) Type guard
def needs_resolution_wh(detections) -> bool:
return detections.mask is not None Prevention
- Always pass the full-frame (width, height) when moving detections that may carry masks.
- Prefer the public InferenceSlicer API, which supplies resolution_wh internally.
When it happens
Trigger: Internally: calling the slicer on a raster/windowed dataset path where resolution_wh is not yet computed. Externally: calling move_detections(detections, offset, resolution_wh=None) on Detections that have .mask set.
Common situations: Using InferenceSlicer with a segmentation callback on a tiff/raster source; custom offset code that forgets to pass the frame resolution when masks are present.
Related errors
- `batch_size` must be a positive integer. Received
- Callback must return `list[Detections]` when `batch_size >…
- Callback returned Detections for slices. Lengths must match.
- InferenceSlicer requires a projected coordinate reference…
- Overlap values must be greater than or equal to 0. Received
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/9df6d8239fd8e38a.
Report an issue: GitHub.
Appendix: source
Thrown at src/supervision/detection/tools/inference_slicer.py:86
format `[dx, dy]`.
resolution_wh: The width and height of the desired mask
resolution. Required for segmentation detections.
Returns:
Repositioned Detections object.
"""
detections = detections.select(slice(None))
detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset)
if ORIENTED_BOX_COORDINATES in detections.data:
detections.data[ORIENTED_BOX_COORDINATES] = move_oriented_boxes(
xyxyxyxy=cast(
npt.NDArray[np.number], detections.data[ORIENTED_BOX_COORDINATES]
),
offset=offset,
)
if detections.mask is not None:
if resolution_wh is None:
raise ValueError(
"Resolution width and height are required for moving segmentation "
"detections. This should be the same as (width, height) of image shape."
)
if isinstance(detections.mask, CompactMask):
# Preserve move_masks clipping semantics without dense materialisation.
detections.mask = detections.mask.with_offset(
dx=int(offset[0]),
dy=int(offset[1]),
new_image_shape=(resolution_wh[1], resolution_wh[0]),
)
else:
detections.mask = move_masks(
masks=detections.mask, offset=offset, resolution_wh=resolution_wh
)
return detections
class InferenceSlicer:View on GitHub (pinned to 7f254d9784)