-
-
Notifications
You must be signed in to change notification settings - Fork 56.6k
Closed
Labels
Description
System Information
- OpenCV Python version: 4.12.0.88
- MacOS: 15.5
- Python version: 3.13.1
Detailed description
In the Python bindings, the 2D Feature detectors that implement detectAndCompute (AKAZE, AffineFeature, BRISK, KAZE, ORB and SIFT) support mask=None (OpenCV Tutorial), but the type stubs do not reflect this.
Based on cbf3b11, 0e17a87, and fc81043, adding to api_refinement seems like the solution.
Steps to reproduce
import cv2
import numpy as np
img = np.zeros((100, 100), dtype=np.uint8)
cv2.SIFT.create().detectAndCompute(img, None)$ python3 repro.py
$ mypy repro.py
repro.py:5: error: No overload variant of "detectAndCompute" of "Feature2D" matches argument types "ndarray[tuple[int, int], dtype[unsignedinteger[_8Bit]]]", "None" [call-overload]
repro.py:5: note: Possible overload variants:
repro.py:5: note: def detectAndCompute(self, image: Mat | ndarray[Any, dtype[integer[Any] | floating[Any]]], mask: Mat | ndarray[Any, dtype[integer[Any] | floating[Any]]], descriptors: Mat | ndarray[Any, dtype[integer[Any] | floating[Any]]] | None = ..., useProvidedKeypoints: bool = ...) -> tuple[Sequence[KeyPoint], Mat | ndarray[Any, dtype[integer[Any] | floating[Any]]]]
repro.py:5: note: def detectAndCompute(self, image: UMat, mask: UMat, descriptors: UMat | None = ..., useProvidedKeypoints: bool = ...) -> tuple[Sequence[KeyPoint], UMat]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