-
-
Notifications
You must be signed in to change notification settings - Fork 56.6k
Closed
Description
System information (version)
- OpenCV => 4.1
- Operating System / Platform => Linux
- Compiler => GCC 8.3.1
Detailed description
When importing cv2 as a Python module and using a tool like mypy or an IDE like PyCharm they have no information about the functions etc. in the module.
I propose adapting the Python API generating script gen2.py to do two things:
- Change the signature description to include type information in the modern Python style.
- Create a Python typing stub file which will allow tools to know what functions are available and what types they expect/return.
By type information in the signature I mean, change for example:
def GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]]) -> dstto
def GaussianBlur(src: Union[Mat, UMat],
ksize: Size,
sigmaX: int,
dst: Optional[Union[Mat, UMat]] = None,
sigmaY: int = 0,
borderType: int = BORDER_DEFAULT
) -> Union[Mat, UMat]Once you have these adapted signature strings, you can put them into a file called __init__.pyi in the cv2 Python directory and the tools will find it.
Even if it is not feasible to get full typing support (due to ambiguity for some types), it will at least provide autocompletion support for IDEs.
Reactions are currently unavailable