fix: typing annotations for cv2.Mat, see #5

This commit is contained in:
283375 2023-07-07 13:32:44 +08:00
parent e01f6cd6bc
commit 922fed8efe
7 changed files with 16 additions and 8 deletions

View File

@ -1,8 +1,7 @@
from typing import Tuple
from cv2 import Mat
from typing import Any, Tuple
from .device import Device
from .types import Mat
__all__ = [
"crop_img",

View File

@ -1,6 +1,8 @@
from cv2 import BORDER_CONSTANT, BORDER_ISOLATED, Mat, bitwise_or, dilate, inRange
from cv2 import BORDER_CONSTANT, BORDER_ISOLATED, bitwise_or, dilate, inRange
from numpy import array, uint8
from .types import Mat
__all__ = [
"GRAY_MIN_HSV",
"GRAY_MAX_HSV",

View File

@ -5,7 +5,6 @@ from cv2 import (
CHAIN_APPROX_SIMPLE,
RETR_EXTERNAL,
TM_CCOEFF_NORMED,
Mat,
boundingRect,
findContours,
imshow,
@ -25,6 +24,7 @@ from .template import (
load_builtin_digit_template,
matchTemplateMultiple,
)
from .types import Mat
__all__ = [
"group_numbers",

View File

@ -1,12 +1,13 @@
from dataclasses import dataclass
from typing import Callable, Optional
from cv2 import COLOR_BGR2HSV, GaussianBlur, Mat, cvtColor, imread
from cv2 import COLOR_BGR2HSV, GaussianBlur, cvtColor, imread
from .crop import *
from .device import Device
from .mask import *
from .ocr import *
from .types import Mat
from .utils import imread_unicode
__all__ = [

View File

@ -11,7 +11,6 @@ from cv2 import (
RETR_EXTERNAL,
THRESH_BINARY_INV,
TM_CCOEFF_NORMED,
Mat,
boundingRect,
cvtColor,
destroyAllWindows,
@ -34,6 +33,7 @@ from ._builtin_templates import (
DEFAULT_REGULAR,
DEFAULT_REGULAR_ERODED,
)
from .types import Mat
__all__ = [
"TemplateItem",

View File

@ -0,0 +1,4 @@
import numpy as np
# from pylance
Mat = np.ndarray[int, np.dtype[np.generic]]

View File

@ -1,7 +1,9 @@
from cv2 import IMREAD_UNCHANGED, Mat, imdecode
from cv2 import IMREAD_UNCHANGED, imdecode
from numpy import fromfile as np_fromfile
from numpy import uint8
from .types import Mat
def imread_unicode(filepath: str) -> Mat:
# https://stackoverflow.com/a/57872297/16484891