{"record":{"id":"149e0b7e744f3f7a","repo":"roboflow/supervision","slug":"only-opencv-s-default-blur-border-is-supported","errorCode":null,"errorMessage":"Only OpenCV's default blur border is supported","messagePattern":"Only OpenCV's default blur border is supported","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/_cv2/_transform.py","lineNumber":20,"sourceCode":"\nfrom __future__ import annotations\n\nfrom typing import Any\n\nimport numpy as np\nimport numpy.typing as npt\n\nfrom supervision._cv2._common import _cast_array_like_opencv\n\n\ndef _blur(\n    image: npt.NDArray[Any], ksize: tuple[int, int], border_type: int = 4\n) -> npt.NDArray[Any]:\n    \"\"\"Apply a box filter with OpenCV's default reflect-101 boundary behavior.\"\"\"\n    if min(ksize) <= 0:\n        raise ValueError(\"Blur kernel dimensions must be positive\")\n    if border_type != 4:\n        raise ValueError(\"Only OpenCV's default blur border is supported\")\n\n    from scipy import ndimage\n\n    size = (*ksize[::-1], 1) if image.ndim == 3 else ksize[::-1]\n    values = ndimage.uniform_filter(image.astype(np.float64), size=size, mode=\"mirror\")\n    return np.ascontiguousarray(_cast_array_like_opencv(values, image.dtype))\n","sourceCodeStart":2,"sourceCodeEnd":27,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/_cv2/_transform.py#L2-L27","documentation":"The fallback blur is implemented with scipy's uniform_filter in 'mirror' mode, which reproduces only OpenCV's default BORDER_REFLECT_101 (border_type == 4) boundary handling. Other cv2 border types (BORDER_CONSTANT, BORDER_REPLICATE, etc.) would change edge results, so they are rejected rather than silently wrong.","triggerScenarios":"Calling cv2.blur(image, ksize, borderType=cv2.BORDER_CONSTANT) or any border type other than 4 (BORDER_DEFAULT) under the fallback.","commonSituations":"Ported OpenCV code that explicitly sets borderType for reproducibility; unlikely to be hit through Supervision's own annotators, which never pass a custom border.","solutions":["Omit borderType (defaults to cv2.BORDER_DEFAULT / 4), which the fallback supports exactly.","Install opencv-python if other border modes are required for correctness."],"exampleFix":"# before\nblurred = cv2.blur(frame, (5, 5), borderType=cv2.BORDER_CONSTANT)\n\n# after\nblurred = cv2.blur(frame, (5, 5))  # BORDER_DEFAULT is the only supported mode","handlingStrategy":"validation","validationCode":"blurred = cv2.blur(image, ksize)  # borderType omitted -> BORDER_DEFAULT (4), the only supported mode","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not set a custom borderType for blur in cv2-free environments","Install opencv-python if border semantics matter to your output"],"tags":["opencv-fallback","blur","border-type","unsupported-feature"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}