{"record":{"id":"9df6d8239fd8e38a","repo":"roboflow/supervision","slug":"resolution-width-and-height-are-required-for-movin","errorCode":null,"errorMessage":"Resolution width and height are required for moving segmentation detections. This should be the same as (width, height) of image shape.","messagePattern":"Resolution width and height are required for moving segmentation detections\\. This should be the same as \\(width, height\\) of image shape\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/tools/inference_slicer.py","lineNumber":86,"sourceCode":"            format `[dx, dy]`.\n        resolution_wh: The width and height of the desired mask\n            resolution. Required for segmentation detections.\n\n    Returns:\n        Repositioned Detections object.\n    \"\"\"\n    detections = detections.select(slice(None))\n    detections.xyxy = move_boxes(xyxy=detections.xyxy, offset=offset)\n    if ORIENTED_BOX_COORDINATES in detections.data:\n        detections.data[ORIENTED_BOX_COORDINATES] = move_oriented_boxes(\n            xyxyxyxy=cast(\n                npt.NDArray[np.number], detections.data[ORIENTED_BOX_COORDINATES]\n            ),\n            offset=offset,\n        )\n    if detections.mask is not None:\n        if resolution_wh is None:\n            raise ValueError(\n                \"Resolution width and height are required for moving segmentation \"\n                \"detections. This should be the same as (width, height) of image shape.\"\n            )\n        if isinstance(detections.mask, CompactMask):\n            # Preserve move_masks clipping semantics without dense materialisation.\n            detections.mask = detections.mask.with_offset(\n                dx=int(offset[0]),\n                dy=int(offset[1]),\n                new_image_shape=(resolution_wh[1], resolution_wh[0]),\n            )\n        else:\n            detections.mask = move_masks(\n                masks=detections.mask, offset=offset, resolution_wh=resolution_wh\n            )\n    return detections\n\n\nclass InferenceSlicer:","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/tools/inference_slicer.py#L68-L104","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nmove_detections(detections=det, offset=np.array([100, 50]), resolution_wh=None)  # ValueError when det.mask is set\n\n# after\nh, w = frame.shape[:2]\nmove_detections(detections=det, offset=np.array([100, 50]), resolution_wh=(w, h))","handlingStrategy":"validation","validationCode":"import numpy as np\n\ndef safe_move(detections, offset, frame=None):\n    resolution_wh = None\n    if detections.mask is not None and frame is not None:\n        h, w = frame.shape[:2]\n        resolution_wh = (w, h)\n    return move_detections(detections=detections, offset=offset, resolution_wh=resolution_wh)","typeGuard":"def needs_resolution_wh(detections) -> bool:\n    return detections.mask is not None","tryCatchPattern":null,"preventionTips":["Always pass the full-frame (width, height) when moving detections that may carry masks.","Prefer the public InferenceSlicer API, which supplies resolution_wh internally."],"tags":["inference-slicer","segmentation-masks","coordinates","valueerror"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}