generated from dopt-python/py311
add test cases for detection module
This commit is contained in:
parent
3963fa8d0b
commit
045b4ddc5b
@ -11,8 +11,22 @@ import dopt_sensor_anomalies.types as t
|
|||||||
def img_paths() -> tuple[Path, ...]:
|
def img_paths() -> tuple[Path, ...]:
|
||||||
img_folder = Path(__file__).parent / "_img"
|
img_folder = Path(__file__).parent / "_img"
|
||||||
if not img_folder.exists():
|
if not img_folder.exists():
|
||||||
raise FileNotFoundError("img path not existing")
|
raise FileNotFoundError("Img path not existing")
|
||||||
return tuple(img_folder.glob("*.bmp"))
|
img_paths = tuple(img_folder.glob("*.bmp"))
|
||||||
|
if not img_paths:
|
||||||
|
raise ValueError("No images found")
|
||||||
|
return img_paths
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def single_img_path() -> Path:
|
||||||
|
img_folder = Path(__file__).parent / "_img"
|
||||||
|
if not img_folder.exists():
|
||||||
|
raise FileNotFoundError("Img path not existing")
|
||||||
|
img_paths = tuple(img_folder.glob("*_12.bmp"))
|
||||||
|
if not img_paths:
|
||||||
|
raise ValueError("No images found")
|
||||||
|
return img_paths[0]
|
||||||
|
|
||||||
|
|
||||||
def test_midpoint():
|
def test_midpoint():
|
||||||
@ -23,7 +37,6 @@ def test_midpoint():
|
|||||||
assert mid_y == 3.0
|
assert mid_y == 3.0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.new
|
|
||||||
def test_check_box_redundancy_SameBox():
|
def test_check_box_redundancy_SameBox():
|
||||||
box_1: t.Box = (
|
box_1: t.Box = (
|
||||||
(64.70450592041016, 505.09185791015625),
|
(64.70450592041016, 505.09185791015625),
|
||||||
@ -38,7 +51,6 @@ def test_check_box_redundancy_SameBox():
|
|||||||
assert detect.check_box_redundancy(box_1, box_2)
|
assert detect.check_box_redundancy(box_1, box_2)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.new
|
|
||||||
def test_check_box_redundancy_DifferentBox():
|
def test_check_box_redundancy_DifferentBox():
|
||||||
box_1: t.Box = (
|
box_1: t.Box = (
|
||||||
(64.70450592041016, 505.09185791015625),
|
(64.70450592041016, 505.09185791015625),
|
||||||
@ -51,3 +63,24 @@ def test_check_box_redundancy_DifferentBox():
|
|||||||
2.35944128036499,
|
2.35944128036499,
|
||||||
)
|
)
|
||||||
assert not detect.check_box_redundancy(box_1, box_2)
|
assert not detect.check_box_redundancy(box_1, box_2)
|
||||||
|
|
||||||
|
|
||||||
|
def test_measure_length(single_img_path):
|
||||||
|
pixels_per_metric_X: float = 0.251
|
||||||
|
pixels_per_metric_Y: float = 0.251
|
||||||
|
data, imgs = detect.measure_length(
|
||||||
|
single_img_path,
|
||||||
|
pixels_per_metric_X,
|
||||||
|
pixels_per_metric_Y,
|
||||||
|
)
|
||||||
|
assert len(data) == 18
|
||||||
|
assert isinstance(data[0], str)
|
||||||
|
assert float(data[0].replace(",", ".")) == pytest.approx(1266.932)
|
||||||
|
img_left = imgs["left"]
|
||||||
|
assert 235 < img_left.shape[0] < 260
|
||||||
|
assert 910 < img_left.shape[1] < 960
|
||||||
|
assert img_left.shape[2] == 3
|
||||||
|
img_right = imgs["right"]
|
||||||
|
assert 235 < img_right.shape[0] < 260
|
||||||
|
assert 910 < img_right.shape[1] < 960
|
||||||
|
assert img_right.shape[2] == 3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user