roboflow/supervision · error · ValueError

Only OpenCV's default blur border is supported

Error message

Only OpenCV's default blur border is supported

What it means

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.

Source

Thrown at src/supervision/_cv2/_transform.py:20

from __future__ import annotations

from typing import Any

import numpy as np
import numpy.typing as npt

from supervision._cv2._common import _cast_array_like_opencv


def _blur(
    image: npt.NDArray[Any], ksize: tuple[int, int], border_type: int = 4
) -> npt.NDArray[Any]:
    """Apply a box filter with OpenCV's default reflect-101 boundary behavior."""
    if min(ksize) <= 0:
        raise ValueError("Blur kernel dimensions must be positive")
    if border_type != 4:
        raise ValueError("Only OpenCV's default blur border is supported")

    from scipy import ndimage

    size = (*ksize[::-1], 1) if image.ndim == 3 else ksize[::-1]
    values = ndimage.uniform_filter(image.astype(np.float64), size=size, mode="mirror")
    return np.ascontiguousarray(_cast_array_like_opencv(values, image.dtype))

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Omit borderType (defaults to cv2.BORDER_DEFAULT / 4), which the fallback supports exactly.
  2. Install opencv-python if other border modes are required for correctness.

Example fix

# before
blurred = cv2.blur(frame, (5, 5), borderType=cv2.BORDER_CONSTANT)

# after
blurred = cv2.blur(frame, (5, 5))  # BORDER_DEFAULT is the only supported mode
Defensive patterns

Strategy: validation

Validate before calling

blurred = cv2.blur(image, ksize)  # borderType omitted -> BORDER_DEFAULT (4), the only supported mode

Prevention

When it happens

Trigger: Calling cv2.blur(image, ksize, borderType=cv2.BORDER_CONSTANT) or any border type other than 4 (BORDER_DEFAULT) under the fallback.

Common situations: Ported OpenCV code that explicitly sets borderType for reproducibility; unlikely to be hit through Supervision's own annotators, which never pass a custom border.

Related errors


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/149e0b7e744f3f7a. Report an issue: GitHub.