* feat(cv2): complete fallback integration * fallback-fixes: reject invalid addWeighted dtype; O(N) approxPolyDP anchor seeding * tests: copyMakeBorder sequence parity; drop non-empty facade-import assert; fix Windows path separator in boundary check * fix(cv2): copyMakeBorder scalar value only fills channel 0 on multichannel images --------- Co-authored-by: Codex <codex@openai.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
100 lines
2.7 KiB
Python
100 lines
2.7 KiB
Python
import os
|
|
|
|
import numpy as np
|
|
from _pytest.fixtures import fixture
|
|
from PIL import Image
|
|
|
|
from supervision import _cv2 as cv2
|
|
|
|
ASSETS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "assets"))
|
|
ALL_IMAGES_LIST = [os.path.join(ASSETS_DIR, f"{i}.jpg") for i in range(1, 6)]
|
|
|
|
|
|
@fixture(scope="function")
|
|
def empty_cv2_image() -> np.ndarray:
|
|
return np.zeros((128, 128, 3), dtype=np.uint8)
|
|
|
|
|
|
@fixture(scope="function")
|
|
def empty_pillow_image() -> Image.Image:
|
|
return Image.new(mode="RGB", size=(128, 128), color=(0, 0, 0))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def all_images() -> list[np.ndarray]:
|
|
return [cv2.imread(path) for path in ALL_IMAGES_LIST]
|
|
|
|
|
|
@fixture(scope="function")
|
|
def one_image() -> np.ndarray:
|
|
return cv2.imread(ALL_IMAGES_LIST[0])
|
|
|
|
|
|
@fixture(scope="function")
|
|
def two_images() -> list[np.ndarray]:
|
|
return [cv2.imread(path) for path in ALL_IMAGES_LIST[:2]]
|
|
|
|
|
|
@fixture(scope="function")
|
|
def three_images() -> list[np.ndarray]:
|
|
return [cv2.imread(path) for path in ALL_IMAGES_LIST[:3]]
|
|
|
|
|
|
@fixture(scope="function")
|
|
def four_images() -> list[np.ndarray]:
|
|
return [cv2.imread(path) for path in ALL_IMAGES_LIST[:4]]
|
|
|
|
|
|
@fixture(scope="function")
|
|
def all_images_tile() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "all_images_tile.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def all_images_tile_and_custom_colors() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "all_images_tile_and_custom_colors.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def all_images_tile_and_custom_grid() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "all_images_tile_and_custom_grid.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def four_images_tile() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "four_images_tile.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def single_image_tile() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "single_image_tile.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def single_image_tile_enforced_grid() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "single_image_tile_enforced_grid.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def three_images_tile() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "three_images_tile.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def two_images_tile() -> np.ndarray:
|
|
return cv2.imread(os.path.join(ASSETS_DIR, "two_images_tile.png"))
|
|
|
|
|
|
@fixture(scope="function")
|
|
def all_images_tile_and_custom_colors_and_titles() -> np.ndarray:
|
|
return cv2.imread(
|
|
os.path.join(ASSETS_DIR, "all_images_tile_and_custom_colors_and_titles.png")
|
|
)
|
|
|
|
|
|
@fixture(scope="function")
|
|
def all_images_tile_and_titles_with_custom_configs() -> np.ndarray:
|
|
return cv2.imread(
|
|
os.path.join(ASSETS_DIR, "all_images_tile_and_titles_with_custom_configs.png")
|
|
)
|