Skip to content

Commit

Permalink
Attempt to fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
WillB97 committed Dec 7, 2024
1 parent 4301fe2 commit 16496e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions april_vision/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Deque, NamedTuple, Optional, Tuple, Union

import cv2
import numpy as np
from numpy.typing import NDArray

from .marker import Marker, PixelCoordinates
Expand Down Expand Up @@ -62,7 +61,7 @@ def annotate_text(
cv2.putText(
frame_type,
text,
np.array(location, dtype=np.int32),
location,
cv2.FONT_HERSHEY_DUPLEX,
text_scale,
color=text_colour, # in BGR
Expand Down
13 changes: 7 additions & 6 deletions april_vision/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyapriltags import Detector

from .frame_sources import FrameSource
from .marker import Marker
from .marker import Marker, PixelCoordinates
from .utils import Frame, normalise_marker_text

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -122,7 +122,7 @@ def _annotate(
for frame_type in frame:
cv2.polylines(
frame_type,
[integer_corners],
integer_corners.tolist(),
isClosed=True,
color=(0, 255, 0), # Green (BGR)
thickness=line_thickness,
Expand All @@ -148,7 +148,7 @@ def _annotate(

cv2.polylines(
frame_type,
[origin_square],
origin_square.tolist(),
isClosed=True,
color=(0, 0, 255), # red
thickness=line_thickness,
Expand All @@ -157,9 +157,10 @@ def _annotate(
marker_text_scale = text_scale * normalise_marker_text(marker)

# Approximately center the text
text_origin = np.array(marker.pixel_centre, dtype=np.int32)
text_origin += np.array(
[-40 * marker_text_scale, 10 * marker_text_scale], dtype=np.int32)
text_origin = PixelCoordinates(
marker.pixel_centre.x - 40 * marker_text_scale,
marker.pixel_centre.y + 10 * marker_text_scale,
)

cv2.putText(
frame_type,
Expand Down

0 comments on commit 16496e5

Please sign in to comment.