"""テスト共通フィクスチャ"""
import numpy as np
import pytest
from common import config
@pytest.fixture()
def straight_line_image() -> np.ndarray:
"""中央に暗い縦線があるグレースケール画像"""
h, w = config.FRAME_HEIGHT, config.FRAME_WIDTH
img = np.full((h, w), 200, dtype=np.uint8)
cx = w // 2
img[:, cx - 1 : cx + 2] = 30
return img
@pytest.fixture()
def blank_image() -> np.ndarray:
"""線のない均一なグレースケール画像"""
h, w = config.FRAME_HEIGHT, config.FRAME_WIDTH
return np.full((h, w), 180, dtype=np.uint8)
@pytest.fixture()
def binary_with_hole() -> np.ndarray:
"""中央に穴がある二値画像(クロージングテスト用)"""
h, w = config.FRAME_HEIGHT, config.FRAME_WIDTH
binary = np.zeros((h, w), dtype=np.uint8)
binary[3:h - 3, w // 2 - 2 : w // 2 + 3] = 255
# 中央に 2px の穴をあける
binary[h // 2 : h // 2 + 2, :] = 0
return binary
@pytest.fixture()
def binary_line() -> np.ndarray:
"""中央に太い白線がある二値画像"""
h, w = config.FRAME_HEIGHT, config.FRAME_WIDTH
binary = np.zeros((h, w), dtype=np.uint8)
cx = w // 2
binary[:, cx - 3 : cx + 4] = 255
return binary