mirror of
https://github.com/scito/extract_otp_secrets.git
synced 2025-12-12 01:41:16 +01:00
improve numpy typing
This commit is contained in:
3
mypy.ini
3
mypy.ini
@@ -1,4 +1 @@
|
|||||||
[mypy]
|
[mypy]
|
||||||
|
|
||||||
[mypy-protobuf_generated_python.*]
|
|
||||||
ignore_errors = True
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ headless: bool = False
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np # TODO use numpy types if available
|
import numpy as np
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import tkinter
|
import tkinter
|
||||||
@@ -405,7 +405,7 @@ def get_color(new_otps_count: int, otp_url: str) -> ColorBGR:
|
|||||||
|
|
||||||
|
|
||||||
# TODO use cv2 types if available
|
# 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 = np.array([raw_pts], np.int32)
|
||||||
pts = pts.reshape((-1, 1, 2))
|
pts = pts.reshape((-1, 1, 2))
|
||||||
cv2.polylines(img, [pts], True, color, BOX_THICKNESS)
|
cv2.polylines(img, [pts], True, color, BOX_THICKNESS)
|
||||||
@@ -413,7 +413,7 @@ def cv2_draw_box(img: Any, raw_pts: Any, color: ColorBGR) -> Any:
|
|||||||
|
|
||||||
|
|
||||||
# TODO use cv2 types if available
|
# 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)
|
window_dim = cv2.getWindowImageRect(WINDOW_NAME)
|
||||||
out_text = text
|
out_text = text
|
||||||
if opposite_len:
|
if opposite_len:
|
||||||
|
|||||||
Reference in New Issue
Block a user