8000 Add type aliases · opencv/opencv@fc63892 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc63892

Browse files
committed
Add type aliases
1 parent d2a0c6c commit fc63892

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

modules/python/src2/gen2.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ def prefixed_lines():
215215
216216
"""
217217

218+
stub_type_aliases = {
219+
"Mat": "np.ndarray",
220+
"Rect": "Sequence[int]",
221+
"Size": "Sequence[int]",
222+
"Size2f": "Sequence[float]",
223+
"UMat": "np.ndarray"
224+
}
225+
218226
class FormatStrings:
219227
string = 's'
220228
unsigned_char = 'b'
@@ -1334,8 +1342,13 @@ def process_isalgorithm(classinfo):
13341342
for name, classinfo in self.classes.items():
13351343
process_isalgorithm(classinfo)
13361344

1337-
# header and enums for stub
1345+
# stub header and type aliases
13381346
self.code_stubs.write(stub_header)
1347+
for alias, type in sorted(stub_type_aliases.items()):
1348+
self.code_stubs.write("{} = {}\n".format(alias, type))
1349+
self.code_stubs.write("\n")
1350+
1351+
# stub enums
13391352
for ns_name, ns in self.namespaces.items():
13401353
self.code_stubs.write("# {}\n".format(ns_name))
13411354
for name in sorted(ns.consts):

0 commit comments

Comments
 (0)
0