-
-
Notifications
You must be signed in to change notification settings - Fork 56.6k
Closed
Description
System Information
OpenCV python version: 4.9.0.80
Operating System / Platform: Windows
Python version: 3.10.11
Detailed description
The type annotations of findContours are too generic.
contours is annotated as ndarray[Any, dtype[generic]], but it should be more specific, at least ndarray[Any, dtype[number]]. This causes mypy to complain about subsequent processing of the return value, such as multiplying it with some number.
Steps to reproduce
import cv2
import numpy as np
mask = np.zeros((4, 4), dtype=np.uint8)
contours, hierarchy = cv2.findContours(mask, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_TC89_KCOS)
contours = contours * 2and check with mypy. mypy throws the following error for the last line:
error: Unsupported operand types for * ("Sequence[Mat | ndarray[Any, dtype[generic]]]" and "int") [operator]
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable