diff --git a/tests/fixtures/approved/test_clip/test_detect_aruco_markers.approved.npy b/tests/fixtures/approved/test_clip/test_detect_aruco_markers.approved.npy new file mode 100644 index 00000000..f41c1f0a Binary files /dev/null and b/tests/fixtures/approved/test_clip/test_detect_aruco_markers.approved.npy differ diff --git a/tests/fixtures/clip/sketch-map-photo.png b/tests/fixtures/clip/sketch-map-photo.png new file mode 100644 index 00000000..330db4a3 Binary files /dev/null and b/tests/fixtures/clip/sketch-map-photo.png differ diff --git a/tests/unit/upload_processing/test_clip.py b/tests/unit/upload_processing/test_clip.py index 8ce3e3a9..5a33e6a2 100644 --- a/tests/unit/upload_processing/test_clip.py +++ b/tests/unit/upload_processing/test_clip.py @@ -2,9 +2,13 @@ import cv2 import pytest +from approvaltests import Options, verify_binary -from sketch_map_tool.upload_processing.clip import clip +from sketch_map_tool.upload_processing.clip import clip, detect_aruco_markers from tests import FIXTURE_DIR +from tests.namer import PytestNamer +from tests.reporter import NDArrayReporter +from tests.unit.helper import serialize_ndarray MAP_CUTTING_FIXTURE_DIR = FIXTURE_DIR / "map-cutting" @@ -115,6 +119,34 @@ def test_clip_failure( # cv2.destroyAllWindows() +@pytest.fixture +def sketch_map_photo(): + raw = cv2.imread(str(FIXTURE_DIR / "clip" / "sketch-map-photo.png")) + return cv2.cvtColor(raw, cv2.COLOR_RGB2BGR) + + +def test_detect_aruco_markers(sketch_map_photo): + marker_corners, marker_ids = detect_aruco_markers(sketch_map_photo) + cv2.aruco.drawDetectedMarkers( + sketch_map_photo, + marker_corners, + marker_ids, + borderColor=(0, 255, 0), # red + ) + # fmt: off + options = ( + Options() + .with_reporter(NDArrayReporter()) + .with_namer(PytestNamer()) + ) + # fmt: on + verify_binary( + serialize_ndarray(sketch_map_photo), + ".npy", + options=options, + ) + + # TODO: Improve map cutting to also work in the case of few features # def test_cut_out_few_features(template_upload_few_features): # template, upload = template_upload_few_features