{"record":{"id":"682ee1e1f029761a","repo":"roboflow/supervision","slug":"resolution-must-be-a-tuple-of-two-int","errorCode":null,"errorMessage":"\n            resolution must be a tuple of two integers, got\n            {type(resolution)} with value {resolution}\n            ","messagePattern":"\n            resolution must be a tuple of two integers, got\n            (.+?) with value (.+?)\n            ","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/validators/__init__.py","lineNumber":336,"sourceCode":"    xy: Any, class_id: Any, confidence: Any, data: dict[str, Any]\n) -> None:\n    void(xy, class_id, confidence, data)\n\n\n@deprecated(  # type: ignore[untyped-decorator]\n    target=_validate_keypoints_fields,\n    deprecated_in=\"0.27.0\",\n    remove_in=\"0.31.0\",\n)\ndef validate_keypoints_fields(\n    xy: Any, class_id: Any, confidence: Any, data: dict[str, Any]\n) -> None:\n    void(xy, class_id, confidence, data)\n\n\ndef _validate_resolution(resolution: Any) -> tuple[int, int]:\n    if not (isinstance(resolution, tuple) and len(resolution) == 2):\n        raise ValueError(\n            f\"\"\"\n            resolution must be a tuple of two integers, got\n            {type(resolution)} with value {resolution}\n            \"\"\"\n        )\n    w, h = resolution\n    if not (isinstance(w, int) and isinstance(h, int)):\n        raise ValueError(\n            f\"\"\"\n            Both elements in resolution must be integers.\n            Got types ({type(w)}, {type(h)})\n            \"\"\"\n        )\n    if w <= 0 or h <= 0:\n        raise ValueError(\n            f\"Both dimensions in resolution must be positive. Got ({w}, {h}).\"\n        )\n    return w, h","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/validators/__init__.py#L318-L354","documentation":"Raised by supervision.validators._validate_resolution when a resolution argument is not a tuple of length 2. Resolution must be a (width, height) tuple of integers, used wherever supervision needs explicit frame/annotator dimensions.","triggerScenarios":"Passing resolution=(1920, 1080, 3) (a 3-tuple including channels), resolution=[1920, 1080] (a list), resolution=1920 (a bare int), or a numpy array.","commonSituations":"Forwarding frame.shape (which is (h, w, c)) as resolution; grabbing video resolution from an API that returns a list; passing width and height as separate positional values instead of one tuple.","solutions":["Pass an explicit 2-tuple: resolution=(1920, 1080).","Derive it from a frame: resolution=(frame.shape[1], frame.shape[0]).","Convert lists: resolution=tuple(resolution) after checking len == 2.","Note supervision uses (width, height) order, unlike NumPy's (h, w)."],"exampleFix":"# before\nframe_info = video_frame.shape  # (1080, 1920, 3)\nobj = SomeAPI(resolution=frame_info)  # 3-tuple -> ValueError\n\n# after\nh, w = video_frame.shape[:2]\nobj = SomeAPI(resolution=(w, h))","handlingStrategy":"validation","validationCode":"if not (isinstance(resolution, tuple) and len(resolution) == 2):\n    h, w = frame.shape[:2]\n    resolution = (int(w), int(h))\nobj = SomeAPI(resolution=resolution)","typeGuard":"def is_valid_resolution_shape(resolution: Any) -> bool:\n    return isinstance(resolution, tuple) and len(resolution) == 2","tryCatchPattern":null,"preventionTips":["Never pass frame.shape (3 elements) as resolution.","Remember supervision uses (width, height) order.","Build resolution explicitly as a 2-tuple at the call site."],"tags":["resolution","validation","configuration","video"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}