Unofficial python stubs for the opencv-python package.
Official OpenCV stubs now exist (in OpenCV>=4.8, cf this issue and this PR), so this repo was archived from 2023/03/27 to 2024/04/13.
However I found the official stubs unhelpful when it came to type hinting, so I'm un-archiving the repo.
This package includes all the functions, classes and constants (please open an issue if you find a missing one).
For some functions, OpenCV may handle more types than defined in this package. If you would like a type/function to be added or modified, please open an issue or a PR. There may also be a few errors as some types have been added programmatically. Please open an issue/PR if you see one.
The stubs include the docstrings as they are otherwise not available in IDEs (as far as I know).
The package is available on pypi here, you can install it with:
pip install opencv-stubsThe dependency on opencv is optional, and can be accessed with:
pip install opencv-stubs[opencv]pip install opencv-stubs[opencv-contrib]pip install opencv-stubs[opencv-headless]
A stub file with opencv functions can be found on the Microsoft stubs repo. This package reused those functions (with some added typing).
- Do something about
cv2.gapi.cv,cv2.utils.cv2andcv2.mat_wrapper.cv(do not duplicate everything if possible). - Handle cases like
cv2.misc.version.cv2.misc.version.cv2.misc.get_ocv_version(). - Only include the
opencv-contribspecific stubs when usingopencv-stubs[opencv-contrib].