8000 opencv-python stubs by Avasam · Pull Request #8879 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

opencv-python stubs #8879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
53cbde4
Bump PyInstaller-stubs to 5.5
Avasam Oct 10, 2022
7f6a836
Merge branch 'master' of https://github.com/python/typeshed
Avasam Oct 10, 2022
517bd33
Initial generated cv2 stubs
Avasam Oct 10, 2022
63d7170
Added microsoft/python-type-stubs/cv2
Avasam Oct 11, 2022
1a00677
Set signatures from existing docstrings
Avasam Oct 11, 2022
aef1b26
Added https://github.com/microsoft/python-type-stubs/pull/219
Avasam Oct 11, 2022
b9224e3
Added https://github.com/microsoft/python-type-stubs/pull/227
Avasam Oct 11, 2022
85f6091
Added https://github.com/microsoft/python-type-stubs/pull/232
Avasam Oct 11, 2022
9fdc94e
Empty docstrings
Avasam Oct 11, 2022
1e3488c
Use the more flexible _Mat (NDArray) for typing
Avasam Oct 11, 2022
b72ac55
Fix dts to dst
Avasam Oct 11, 2022
41dba77
Added missing packages + strict types in cv2.gapi
Avasam Oct 12, 2022
edfd948
Updated list to Sequence in method args
Avasam Oct 12, 2022
8b35a5a
stricter pyright
Avasam Oct 12, 2022
e2c4a41
Fix Flake8
Avasam Oct 12, 2022
7e8b5dd
complete some Incomplete
Avasam Oct 12, 2022
6e5ab28
Removed docstrings
Avasam Oct 12, 2022
9cf3c44
fix pyright test
Avasam Oct 12, 2022
6a03195
Fixed Mat variances
Avasam Oct 12, 2022
f75c2f9
fixed cv2.error and cv2.Error
Avasam Oct 12, 2022
7fb76ea
Flake8 and stubtest
Avasam Oct 12, 2022
c9431d2
don't return Any with # incomplete method
Avasam Oct 14, 2022
0a688b7
don't return Any with # incomplete method
Avasam Oct 14, 2022
900e731
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 14, 2022
37bb1d1
Class def updates
Avasam Oct 15, 2022
ebe36a1
Merge branch 'opencv2' of https://github.com/Avasam/typeshed into ope…
Avasam Oct 15, 2022
06f73ba
Additional comments
Avasam Oct 15, 2022
c66b19c
Move _RotatedRect
Avasam Oct 15, 2022
203de26
mypy type: ignore[misc] explanation comment
Avasam Oct 15, 2022
28dc455
Completed generated modules
Avasam Oct 19, 2022
ffcfcee
Merge branch 'master' of https://github.com/python/typeshed into opencv2
Avasam Oct 20, 2022
bb50269
Fix flake8 warnings
Avasam Oct 20, 2022
22f29a7
Merge branch 'python:main' into opencv2
Avasam Nov 12, 2022
6b35384
Merge branch 'main' of https://github.com/python/typeshed into opencv2
Avasam Dec 5, 2022
6919768
noqa: Y042" has no matching violations
Avasam Dec 5, 2022
6d21d55
Merge branch 'main' into opencv2
AlexWaygood Jan 11, 2023
3b4f9b3
Merge branch 'main' of https://github.com/python/typeshed into opencv2
Avasam Jun 5, 2023
bfd370d
Merge branch 'opencv2' of https://github.com/Avasam/typeshed into ope…
Avasam Jun 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated list to Sequence in method args
- Can't parse 'org_'. Input argument doesn't provide sequence protocol
  • Loading branch information
Avasam committed Oct 12, 2022
commit edfd948efe643b369932f70d494d8ba2381555a2
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"stubs/pytz/pytz/tzfile.pyi",
"stubs/google-cloud-ndb",
"stubs/opencv-python/cv2/cv2.pyi",
"stubs/opencv-python/cv2/detail.pyi",
"stubs/opencv-python/cv2/utils/__init__.pyi",
"stubs/paho-mqtt",
"stubs/passlib",
Expand Down
38 changes: 20 additions & 18 deletions stubs/opencv-python/cv2/cv2.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from typing import Any, ClassVar, Sequence, overload
from collections.abc import Sequence
from typing import Any, ClassVar, overload
from typing_extensions import TypeAlias

from cv2.gapi.streaming import queue_capacity
Expand Down Expand Up @@ -3415,8 +3416,7 @@ class gapi_wip_draw_Text:
org: tuple[int, int]
text: str
thick: int
# TODO: org_ should have exactly two values
def __init__(self, text_: str, org_: Sequence[int], ff_: int, fs_: float, color_: _Scalar) -> None: ...
def __init__(self, text_: str, org_: tuple[int, int], ff_: int, fs_: float, color_: _Scalar) -> None: ...

class ml_ANN_MLP(ml_StatModel):
def __init__(self, *args, **kwargs) -> None: ... # incomplete
Expand Down Expand Up @@ -4033,7 +4033,7 @@ def HoughCircles(
you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number
to return centers only without radius search, and find the correct radius using an additional procedure.

It also helps to smooth image a bit unless it\'s already soft. For example,
It also helps to smooth image a bit unless it's already soft. For example,
GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.

@param image 8-bit, single-channel, grayscale input image.
Expand Down Expand Up @@ -5239,7 +5239,9 @@ def buildOpticalFlowPyramid(
"""
...

def calcBackProject(images: list[_Mat], channels: list[int], hist, ranges: list[int], scale, dst: _Mat = ...) -> _dst: ...
def calcBackProject(
images: Sequence[_Mat], channels: Sequence[int], hist, ranges: Sequence[int], scale, dst: _Mat = ...
) -> _dst: ...
def calcCovarMatrix(samples, mean, flags: int, covar=..., ctype=...) -> tuple[_covar, _mean]:
"""
@note use #COVAR_ROWS or #COVAR_COLS flag
Expand All @@ -5252,11 +5254,11 @@ def calcCovarMatrix(samples, mean, flags: int, covar=..., ctype=...) -> tuple[_c
...

def calcHist(
images: list[_Mat],
channels: list[int],
images: Sequence[_Mat],
channels: Sequence[int],
mask: _Mat | None,
histSize: list[int],
ranges: list[int],
histSize: Sequence[int],
ranges: Sequence[int],
hist: _Mat = ...,
accumulate=...,
) -> _Mat: ...
Expand Down Expand Up @@ -9635,7 +9637,7 @@ def imread(filename: str, flags: int = ...) -> _Mat:
@note
- The function determines the type of an image by the content, not by the file extension.
- In the case of color images, the decoded images will have the channels stored in **B G R** order.
- When using IMREAD_GRAYSCALE, the codec\'s internal grayscale conversion will be used, if available.
- When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
Results may differ to the output of cvtColor()
- On Microsoft Windows * OS and MacOSX * , the codecs shipped with an OpenCV image (libjpeg,
libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
Expand Down Expand Up @@ -9696,7 +9698,7 @@ def imshow(winname, mat) -> None:
If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.

@note This function should be followed by cv::waitKey function which displays the image for specified
milliseconds. Otherwise, it won\'t 10000 display the image. For example, **waitKey(0)** will display the window
milliseconds. Otherwise, it won't display the image. For example, **waitKey(0)** will display the window
infinitely until any keypress (it is suitable for image display). **waitKey(25)** will display a frame
for 25 ms, after which display will be automatically closed. (If you put it in a loop to read
videos, it will display the video frame-by-frame)
Expand All @@ -9712,7 +9714,7 @@ def imshow(winname, mat) -> None:
"""
...

def imwrite(filename: str, img: _Mat, params: list[int] = ...) -> bool:
def imwrite(filename: str, img: _Mat, params: Sequence[int] = ...) -> bool:
"""
@brief Saves an image to a specified file.

Expand Down Expand Up @@ -10532,7 +10534,7 @@ def mulTransposed(src: _Mat, aTa, dst: _Mat = ..., delta=..., scale=..., dtype=.
[`dst` = `scale` ( `src` - `delta` ) ( `src` - `delta` )^T]
otherwise. The function is used to calculate the covariance matrix. With
zero delta, it can be used as a faster substitute for general matrix
product A * B when B=A\'
product A * B when B=A'
@param src input single-channel matrix. Note that unlike gemm, the
function can multiply not only floating-point matrices.
@param dst output square matrix.
Expand Down Expand Up @@ -11877,7 +11879,7 @@ def solveLP(Func, Constr, z=...) -> tuple[_retval, _z]:

The particular implementation is taken almost verbatim from **Introduction to Algorithms, third
edition** by T. H. Cormen, C. E. Leiserson, R. L. Rivest and Clifford Stein. In particular, the
Bland\'s rule <http://en.wikipedia.org/wiki/Bland%27s_rule> is used to prevent cycling.
Bland's rule <http://en.wikipedia.org/wiki/Bland%27s_rule> is used to prevent cycling.

@param Func This row-vector corresponds to `c` in the LP problem formulation (see above). It should
contain 32- or 64-bit floating point numbers. As a convenience, column-vector may be also submitted,
Expand Down Expand Up @@ -12081,7 +12083,7 @@ def solvePnP(
- An example of how to use solvePnP for planar augmented reality can be found at
opencv_source_code/samples/python/plane_ar.py
- If you are using Python:
- Numpy array slices won\'t work as input because solvePnP requires contiguous
- Numpy array slices won't work as input because solvePnP requires contiguous
arrays (enforced by the assertion using cv::_Mat::checkVector() around line 55 of
modules/calib3d/src/solvepnp.cpp version 2.4.9)
- The P3P algorithm requires image points to be in an array of shape (N,1,2) due
Expand Down Expand Up @@ -12286,7 +12288,7 @@ def solvePnPGeneric(
- An example of how to use solvePnP for planar augmented reality can be found at
opencv_source_code/samples/python/plane_ar.py
- If you are using Python:
- Numpy array slices won\'t work as input because solvePnP requires contiguous
- Numpy array slices won't work as input because solvePnP requires contiguous
arrays (enforced by the assertion using cv::_Mat::checkVector() around line 55 of
modules/calib3d/src/solvepnp.cpp version 2.4.9)
- The P3P algorithm requires image points to be in an array of shape (N,1,2) due
Expand Down Expand Up @@ -13356,12 +13358,12 @@ def watershed(image: _Mat, markers) -> _markers:
components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary
mask using #findContours and #drawContours (see the watershed.cpp demo). The markers are "seeds" of
the future image regions. All the other pixels in markers , whose relation to the outlined regions
is not known and should be defined by the algorithm, should be set to 0\'s. In the function output,
is not known and should be defined by the algorithm, should be set to 0's. In the function output,
each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the
regions.

@note Any two neighbor connected components are not necessarily separated by a watershed boundary
(-1\'s pixels); for example, they can touch each other in the initial marker image passed to the
(-1's pixels); for example, they can touch each other in the initial marker image passed to the
function.

@param image Input 8-bit 3-channel image.
Expand Down
30 changes: 15 additions & 15 deletions stubs/opencv-python/cv2/detail.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,28 @@ WAVE_CORRECT_AUTO: int
WAVE_CORRECT_HORIZ: int
WAVE_CORRECT_VERT: int

def BestOf2NearestMatcher_create(*args, **kwargs) -> Any: ...
def Blender_createDefault(*args, **kwargs) -> Any: ...
def ExposureCompensator_createDefault(*args, **kwargs) -> Any: ...
def SeamFinder_createDefault(*args, **kwargs) -> Any: ...
def Timelapser_createDefault(*args, **kwargs) -> Any: ...
def calibrateRotatingCamera(*args, **kwargs) -> Any: ...
def computeImageFeatures(*args, **kwargs) -> Any: ...
def computeImageFeatures2(*args, **kwargs) -> Any: ...
def BestOf2NearestMatcher_create(*args, **kwargs) -> Any: ... # incomplete
def Blender_createDefault(*args, **kwargs) -> Any: ... # incomplete
def ExposureCompensator_createDefault(*args, **kwargs) -> Any: ... # incomplete
def SeamFinder_createDefault(*args, **kwargs) -> Any: ... # incomplete
def Timelapser_createDefault(*args, **kwargs) -> Any: ... # incomplete
def calibrateRotatingCamera(*args, **kwargs) -> Any: ... # incomplete
def computeImageFeatures(*args, **kwargs) -> Any: ... # incomplete
def computeImageFeatures2(*args, **kwargs) -> Any: ... # incomplete
def createLaplacePyr(img, num_levels, pyr) -> _pyr: ...
def createLaplacePyrGpu(img, num_levels, pyr) -> _pyr: ...
def createWeightMap(mask, sharpness, weight) -> _weight: ...
def focalsFromHomography(H, f0, f1, f0_ok, f1_ok) -> None: ...
def leaveBiggestComponent(*args, **kwargs) -> Any: ...
def matchesGraphAsString(*args, **kwargs) -> Any: ...
def leaveBiggestComponent(*args, **kwargs) -> Any: ... # incomplete
def matchesGraphAsString(*args, **kwargs) -> Any: ... # incomplete
def normalizeUsingWeightMap(weight, src) -> _src: ...
def overlapRoi(*args, **kwargs) -> Any: ...
def overlapRoi(*args, **kwargs) -> Any: ... # incomplete
def restoreImageFromLaplacePyr(pyr) -> _pyr: ...
def restoreImageFromLaplacePyrGpu(pyr) -> _pyr: ...
def resultRoi(*args, **kwargs) -> Any: ...
def resultRoiIntersection(*args, **kwargs) -> Any: ...
def resultTl(*args, **kwargs) -> Any: ...
def resultRoi(*args, **kwargs) -> Any: ... # incomplete
def resultRoiIntersection(*args, **kwargs) -> Any: ... # incomplete
def resultTl(*args, **kwargs) -> Any: ... # incomplete
def selectRandomSubset(count, size, subset) -> None: ...
def stitchingLogLevel(*args, **kwargs) -> Any: ...
def stitchingLogLevel(*args, **kwargs) -> Any: ... # incomplete
def strip(params: gapi_ie_PyParams): ...
def waveCorrect(rmats, kind) -> _rmats: ...
0