Skip to content

Commit

Permalink
feat(clip): detect aruco markers
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasschaub committed Nov 13, 2024
1 parent 21a48d1 commit 91a4161
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
Binary file not shown.
Binary file added tests/fixtures/clip/sketch-map-photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion tests/unit/upload_processing/test_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 91a4161

Please sign in to comment.