[mypy] annotate computer_vision (#5571)

This commit is contained in:
Erwin Junge 2021-10-23 23:26:21 +02:00 committed by GitHub
parent 00a67010e8
commit aaaa175b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,11 +21,11 @@ class Harris_Corner:
else: else:
raise ValueError("invalid k value") raise ValueError("invalid k value")
def __str__(self): def __str__(self) -> str:
return f"Harris Corner detection with k : {self.k}" return f"Harris Corner detection with k : {self.k}"
def detect(self, img_path: str): def detect(self, img_path: str) -> tuple[cv2.Mat, list[list[int]]]:
""" """
Returns the image with corners identified Returns the image with corners identified
@ -35,7 +35,7 @@ class Harris_Corner:
img = cv2.imread(img_path, 0) img = cv2.imread(img_path, 0)
h, w = img.shape h, w = img.shape
corner_list = [] corner_list: list[list[int]] = []
color_img = img.copy() color_img = img.copy()
color_img = cv2.cvtColor(color_img, cv2.COLOR_GRAY2RGB) color_img = cv2.cvtColor(color_img, cv2.COLOR_GRAY2RGB)
dy, dx = np.gradient(img) dy, dx = np.gradient(img)