python-opencv-utils 0.0.4__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cv2u/__init__.py +247 -5
- cv2u/_cv2_exports.pyi +4992 -0
- cv2u/core/__init__.py +40 -3
- cv2u/core/cluster.py +287 -21
- cv2u/core/compose.py +199 -0
- cv2u/core/extension.py +101 -37
- cv2u/core/images.py +62 -0
- cv2u/core/layout.py +130 -0
- cv2u/core/peaks.py +172 -0
- cv2u/core/roi.py +121 -0
- cv2u/core/rotate.py +32 -7
- cv2u/flag.py +66 -0
- cv2u/highgui/__init__.py +3 -0
- cv2u/highgui/display.py +64 -0
- cv2u/imgcodecs/__init__.py +5 -2
- cv2u/imgcodecs/convert.py +121 -0
- cv2u/imgcodecs/files.py +67 -0
- cv2u/imgcodecs/urlread.py +33 -6
- cv2u/imgproc/__init__.py +46 -1
- cv2u/imgproc/adjust.py +139 -0
- cv2u/imgproc/color.py +106 -0
- cv2u/imgproc/draw.py +261 -0
- cv2u/imgproc/edges.py +36 -0
- cv2u/imgproc/enhance.py +77 -0
- cv2u/imgproc/geometry.py +81 -0
- cv2u/imgproc/mask.py +182 -0
- cv2u/imgproc/puttext.py +40 -6
- cv2u/imgproc/quality.py +86 -0
- cv2u/imgproc/resize.py +93 -0
- cv2u/imgproc/template.py +64 -0
- cv2u/py.typed +0 -0
- cv2u/videoio/__init__.py +3 -0
- cv2u/videoio/video.py +200 -0
- python_opencv_utils-0.1.0.dist-info/METADATA +392 -0
- python_opencv_utils-0.1.0.dist-info/RECORD +38 -0
- {python_opencv_utils-0.0.4.dist-info → python_opencv_utils-0.1.0.dist-info}/WHEEL +1 -2
- python_opencv_utils-0.1.0.dist-info/licenses/NOTICE +4 -0
- cv2u/imgcodecs/gradient.py +0 -20
- cv2u/imgcodecs/images.py +0 -29
- python_opencv_utils-0.0.4.dist-info/METADATA +0 -128
- python_opencv_utils-0.0.4.dist-info/RECORD +0 -17
- python_opencv_utils-0.0.4.dist-info/top_level.txt +0 -1
- {python_opencv_utils-0.0.4.dist-info → python_opencv_utils-0.1.0.dist-info/licenses}/LICENSE +0 -0
cv2u/__init__.py
CHANGED
|
@@ -1,5 +1,247 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"""Python OpenCV Utilities.
|
|
2
|
+
|
|
3
|
+
``cv2u`` is a drop-in replacement for ``cv2``. Import it the same way the
|
|
4
|
+
official OpenCV documentation imports ``cv2`` (``import cv2 as cv``)::
|
|
5
|
+
|
|
6
|
+
import cv2u as cv
|
|
7
|
+
|
|
8
|
+
Every attribute that ``cv2u`` does not define itself is looked up on the
|
|
9
|
+
``cv2`` module, so ``cv.imread``, ``cv.COLOR_BGR2GRAY``, ``cv.dnn`` and so on
|
|
10
|
+
all work as usual, alongside the extensions provided by this package.
|
|
11
|
+
|
|
12
|
+
Requires OpenCV 5.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
16
|
+
from typing import TYPE_CHECKING, Any
|
|
17
|
+
|
|
18
|
+
import cv2 as _cv2
|
|
19
|
+
|
|
20
|
+
if int(_cv2.__version__.split(".")[0]) < 5:
|
|
21
|
+
# Another distribution (e.g. opencv-contrib-python 4.x) may provide ``cv2`` alongside ours.
|
|
22
|
+
raise ImportError(
|
|
23
|
+
f"cv2u requires OpenCV 5 or newer, but cv2 {_cv2.__version__} is installed "
|
|
24
|
+
f"({_cv2.__file__}). Upgrade it with: pip install -U 'opencv-python>=5'"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
# Lets type checkers and IDEs see OpenCV's own signatures (``cv.imread`` etc.).
|
|
29
|
+
# At runtime these names come from ``__getattr__`` below.
|
|
30
|
+
from . import _cv2_exports
|
|
31
|
+
from ._cv2_exports import * # noqa: F403
|
|
32
|
+
|
|
33
|
+
from .core import (
|
|
34
|
+
DBSCAN,
|
|
35
|
+
DHEdge,
|
|
36
|
+
cartesianToPolar,
|
|
37
|
+
centerPoint,
|
|
38
|
+
clusterPoints,
|
|
39
|
+
colorQuantize,
|
|
40
|
+
cropEx,
|
|
41
|
+
cropToContent,
|
|
42
|
+
dominantColors,
|
|
43
|
+
drawDBSCAN,
|
|
44
|
+
gammaCorrection,
|
|
45
|
+
hconcatEx,
|
|
46
|
+
imcolor,
|
|
47
|
+
imcolorLike,
|
|
48
|
+
inRangeEx,
|
|
49
|
+
isInside,
|
|
50
|
+
kmeansColors,
|
|
51
|
+
makeGradient,
|
|
52
|
+
meanShiftColors,
|
|
53
|
+
mergeTiles,
|
|
54
|
+
montage,
|
|
55
|
+
overlayImage,
|
|
56
|
+
padToMultiple,
|
|
57
|
+
padToSize,
|
|
58
|
+
peakColors,
|
|
59
|
+
polarToCartesian,
|
|
60
|
+
rotateEx,
|
|
61
|
+
splitTiles,
|
|
62
|
+
vconcatEx,
|
|
63
|
+
)
|
|
64
|
+
from .flag import (
|
|
65
|
+
ALL_CONTOURS,
|
|
66
|
+
DDEPTH_SAME,
|
|
67
|
+
FLIP_MODE_X,
|
|
68
|
+
FLIP_MODE_XY,
|
|
69
|
+
FLIP_MODE_Y,
|
|
70
|
+
KEY_BACKSPACE,
|
|
71
|
+
KEY_ENTER,
|
|
72
|
+
KEY_ESC,
|
|
73
|
+
KEY_SPACE,
|
|
74
|
+
KEY_TAB,
|
|
75
|
+
REDUCE_TO_COL,
|
|
76
|
+
REDUCE_TO_ROW,
|
|
77
|
+
WAIT_FOREVER,
|
|
78
|
+
)
|
|
79
|
+
from .highgui import (
|
|
80
|
+
imshowEx,
|
|
81
|
+
imshowInline,
|
|
82
|
+
)
|
|
83
|
+
from .imgcodecs import (
|
|
84
|
+
fromPillow,
|
|
85
|
+
imdecodeBase64,
|
|
86
|
+
imencodeBase64,
|
|
87
|
+
imreadEx,
|
|
88
|
+
imwriteEx,
|
|
89
|
+
toPillow,
|
|
90
|
+
urlread,
|
|
91
|
+
)
|
|
92
|
+
from .imgproc import (
|
|
93
|
+
adjustBrightnessContrast,
|
|
94
|
+
adjustHSV,
|
|
95
|
+
autoCanny,
|
|
96
|
+
autoContrast,
|
|
97
|
+
bgrToHex,
|
|
98
|
+
cutout,
|
|
99
|
+
diffMask,
|
|
100
|
+
drawDashedLine,
|
|
101
|
+
drawDashedRectangle,
|
|
102
|
+
drawHistogram,
|
|
103
|
+
drawLabel,
|
|
104
|
+
equalizeHistEx,
|
|
105
|
+
fillHoles,
|
|
106
|
+
findContoursEx,
|
|
107
|
+
findTemplate,
|
|
108
|
+
fourPointTransform,
|
|
109
|
+
hexToBGR,
|
|
110
|
+
largestComponent,
|
|
111
|
+
letterbox,
|
|
112
|
+
overlayMask,
|
|
113
|
+
putTextEx,
|
|
114
|
+
removeSmallObjects,
|
|
115
|
+
resizeEx,
|
|
116
|
+
sharpnessScore,
|
|
117
|
+
skeletonize,
|
|
118
|
+
ssim,
|
|
119
|
+
toBGR,
|
|
120
|
+
toBGRA,
|
|
121
|
+
toGray,
|
|
122
|
+
translate,
|
|
123
|
+
unsharpMask,
|
|
124
|
+
whiteBalance,
|
|
125
|
+
)
|
|
126
|
+
from .videoio import (
|
|
127
|
+
VideoInfo,
|
|
128
|
+
readFrameAt,
|
|
129
|
+
readFrames,
|
|
130
|
+
videoInfo,
|
|
131
|
+
writeVideo,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
__version__ = version("python-opencv-utils")
|
|
136
|
+
except PackageNotFoundError: # pragma: no cover - running from a source tree that is not installed
|
|
137
|
+
__version__ = "0.0.0"
|
|
138
|
+
|
|
139
|
+
# Only the cv2u extensions. OpenCV names are reachable as attributes, not through ``import *``.
|
|
140
|
+
__all__ = [
|
|
141
|
+
"ALL_CONTOURS",
|
|
142
|
+
"DBSCAN",
|
|
143
|
+
"DDEPTH_SAME",
|
|
144
|
+
"FLIP_MODE_X",
|
|
145
|
+
"FLIP_MODE_XY",
|
|
146
|
+
"FLIP_MODE_Y",
|
|
147
|
+
"KEY_BACKSPACE",
|
|
148
|
+
"KEY_ENTER",
|
|
149
|
+
"KEY_ESC",
|
|
150
|
+
"KEY_SPACE",
|
|
151
|
+
"KEY_TAB",
|
|
152
|
+
"REDUCE_TO_COL",
|
|
153
|
+
"REDUCE_TO_ROW",
|
|
154
|
+
"WAIT_FOREVER",
|
|
155
|
+
"DHEdge",
|
|
156
|
+
"VideoInfo",
|
|
157
|
+
"adjustBrightnessContrast",
|
|
158
|
+
"adjustHSV",
|
|
159
|
+
"autoCanny",
|
|
160
|
+
"autoContrast",
|
|
161
|
+
"bgrToHex",
|
|
162
|
+
"cartesianToPolar",
|
|
163
|
+
"centerPoint",
|
|
164
|
+
"clusterPoints",
|
|
165
|
+
"colorQuantize",
|
|
166
|
+
"cropEx",
|
|
167
|
+
"cropToContent",
|
|
168
|
+
"cutout",
|
|
169
|
+
"diffMask",
|
|
170
|
+
"dominantColors",
|
|
171
|
+
"drawDBSCAN",
|
|
172
|
+
"drawDashedLine",
|
|
173
|
+
"drawDashedRectangle",
|
|
174
|
+
"drawHistogram",
|
|
175
|
+
"drawLabel",
|
|
176
|
+
"equalizeHistEx",
|
|
177
|
+
"fillHoles",
|
|
178
|
+
"findContoursEx",
|
|
179
|
+
"findTemplate",
|
|
180
|
+
"fourPointTransform",
|
|
181
|
+
"fromPillow",
|
|
182
|
+
"gammaCorrection",
|
|
183
|
+
"hconcatEx",
|
|
184
|
+
"hexToBGR",
|
|
185
|
+
"imcolor",
|
|
186
|
+
"imcolorLike",
|
|
187
|
+
"imdecodeBase64",
|
|
188
|
+
"imencodeBase64",
|
|
189
|
+
"imreadEx",
|
|
190
|
+
"imshowEx",
|
|
191
|
+
"imshowInline",
|
|
192
|
+
"imwriteEx",
|
|
193
|
+
"inRangeEx",
|
|
194
|
+
"isInside",
|
|
195
|
+
"kmeansColors",
|
|
196
|
+
"largestComponent",
|
|
197
|
+
"letterbox",
|
|
198
|
+
"makeGradient",
|
|
199
|
+
"meanShiftColors",
|
|
200
|
+
"mergeTiles",
|
|
201
|
+
"montage",
|
|
202
|
+
"overlayImage",
|
|
203
|
+
"overlayMask",
|
|
204
|
+
"padToMultiple",
|
|
205
|
+
"padToSize",
|
|
206
|
+
"peakColors",
|
|
207
|
+
"polarToCartesian",
|
|
208
|
+
"putTextEx",
|
|
209
|
+
"readFrameAt",
|
|
210
|
+
"readFrames",
|
|
211
|
+
"removeSmallObjects",
|
|
212
|
+
"resizeEx",
|
|
213
|
+
"rotateEx",
|
|
214
|
+
"sharpnessScore",
|
|
215
|
+
"skeletonize",
|
|
216
|
+
"splitTiles",
|
|
217
|
+
"ssim",
|
|
218
|
+
"toBGR",
|
|
219
|
+
"toBGRA",
|
|
220
|
+
"toGray",
|
|
221
|
+
"toPillow",
|
|
222
|
+
"translate",
|
|
223
|
+
"unsharpMask",
|
|
224
|
+
"urlread",
|
|
225
|
+
"vconcatEx",
|
|
226
|
+
"videoInfo",
|
|
227
|
+
"whiteBalance",
|
|
228
|
+
"writeVideo",
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
if TYPE_CHECKING:
|
|
232
|
+
# Mark the OpenCV names as public API of this typed package (pyright's reportPrivateImportUsage,
|
|
233
|
+
# mypy's --no-implicit-reexport). Runtime ``from cv2u import *`` still exports only the extensions.
|
|
234
|
+
__all__ += _cv2_exports.__all__
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def __getattr__(name: str) -> Any:
|
|
238
|
+
# OpenCV's ``cv2/__init__.py`` defines ``__all__ = []``, so
|
|
239
|
+
# ``from cv2 import *`` re-exports nothing. Delegate lookups instead.
|
|
240
|
+
try:
|
|
241
|
+
return getattr(_cv2, name)
|
|
242
|
+
except AttributeError:
|
|
243
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def __dir__() -> list[str]:
|
|
247
|
+
return sorted(set(globals()) | set(dir(_cv2)))
|