update test cases

This commit is contained in:
SkalskiP 2025-04-22 20:07:54 +02:00
parent 5d6ad66618
commit 6387513805
1 changed files with 23 additions and 19 deletions

View File

@ -1409,26 +1409,30 @@ def test_xyxy_to_xywh(xyxy: np.ndarray, expected_result: np.ndarray) -> None:
@pytest.mark.parametrize(
"xyxy, expected_result",
[
(
np.array([[10, 20, 40, 60]]),
np.array([[25, 40, 0.75, 40]]),
), # standard case
(np.array([[0, 0, 0, 0]]), np.array([[0, 0, 0.0, 0]])),
# zero size bounding box
(
np.array([[50, 50, 150, 150]]),
np.array([[100, 100, 1.0, 100]]),
), # square bounding box
(
np.array([[-10, -20, 20, 20]]),
np.array([[5, 0, 0.75, 40]]),
), # negative coordinates
(
np.array([[50, 50, 50, 80]]),
np.array([[50, 65, 0.0, 30]]),
), # zero width
(np.array([[50, 50, 70, 50]]), np.array([[60, 50, 0.0, 0]])), # zero height
# Empty and zero cases
(np.array([]).reshape(0, 4), np.array([]).reshape(0, 4)), # empty array
(np.array([[0, 0, 0, 0]]), np.array([[0, 0, 0.0, 0]])), # zero size bounding box
(np.array([[10, 10, 10, 10]]), np.array([[10, 10, 0.0, 0]])), # point (x1=x2, y1=y2)
# Zero width/height cases
(np.array([[50, 50, 80, 50]]), np.array([[65, 50, 0.0, 0]])), # zero height
(np.array([[50, 50, 50, 80]]), np.array([[50, 65, 0.0, 30]])), # zero width
# Standard cases
(np.array([[10, 20, 40, 60]]), np.array([[25, 40, 0.75, 40]])), # standard case
(np.array([[-30, -40, -10, -20]]), np.array([[-20, -30, 1.0, 20]])), # all negative values
(np.array([[0.1, 0.2, 0.4, 0.6]]), np.array([[0.25, 0.4, 0.75, 0.4]])), # values between 0-1
# Different aspect ratios
(np.array([[10, 20, 50, 100]]), np.array([[30, 60, 0.5, 80]])), # tall rectangle (height > width)
(np.array([[20, 10, 100, 50]]), np.array([[60, 30, 2.0, 40]])), # wide rectangle (width > height)
(np.array([[50, 50, 150, 150]]), np.array([[100, 100, 1.0, 100]])), # height == width
# Multiple boxes in one array
(
np.array([[0, 0, 0, 0], [10, 20, 40, 60]]),
np.array([[0, 0, 0.0, 0], [25, 40, 0.75, 40]]),
), # one zero-sized box and one normal box
],
)
def test_xyxy_to_xcycarh(xyxy: np.ndarray, expected_result: np.ndarray) -> None: