Skip to content

Commit

Permalink
improve numpy typing
Browse files Browse the repository at this point in the history
  • Loading branch information
scito committed Aug 6, 2023
1 parent 2610afe commit 0b47a37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
[mypy]

[mypy-protobuf_generated_python.*]
ignore_errors = True
6 changes: 3 additions & 3 deletions src/extract_otp_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

try:
import cv2
import numpy as np # TODO use numpy types if available
import numpy as np

try:
import tkinter
Expand Down Expand Up @@ -405,15 +405,15 @@ def get_color(new_otps_count: int, otp_url: str) -> ColorBGR:


# TODO use cv2 types if available
def cv2_draw_box(img: Any, raw_pts: Any, color: ColorBGR) -> Any:
def cv2_draw_box(img: list[tuple[Any, Any]], raw_pts: list[tuple[Any, Any]], color: ColorBGR) -> np.ndarray[Any, np.dtype[np.int32]]:
pts = np.array([raw_pts], np.int32)
pts = pts.reshape((-1, 1, 2))
cv2.polylines(img, [pts], True, color, BOX_THICKNESS)
return pts


# TODO use cv2 types if available
def cv2_print_text(img: Any, text: str, line_number: int, position: TextPosition, color: ColorBGR, opposite_len: Optional[int] = None) -> None:
def cv2_print_text(img: cv2.UMat, text: str, line_number: int, position: TextPosition, color: ColorBGR, opposite_len: Optional[int] = None) -> None:
window_dim = cv2.getWindowImageRect(WINDOW_NAME)
out_text = text
if opposite_len:
Expand Down

0 comments on commit 0b47a37

Please sign in to comment.