Skip to content

Commit 4745beb

Browse files
committed
add ability to patch declarations
1 parent 9f016c3 commit 4745beb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gen_rust.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,21 @@ def _base_type_alias(module, rust_name, rust_definition, cpp_field_type, cpp_fie
612612
# list of modules that are imported into every other module so there is no need to reference them using full path, elements are module names
613613
static_modules = ("core", "sys", "types")
614614

615+
616+
def decl_patch(module, decl):
617+
if module == "objdetect":
618+
# replace Mat with explicit vector because detect functions only accept vector InputArray
619+
if decl[0] == "cv.QRCodeDetector.detect" or decl[0] == "cv.QRCodeDetector.detectAndDecode":
620+
pts_arg = decl[3][1]
621+
if pts_arg[0] == "OutputArray" and pts_arg[1] == "points":
622+
decl[3][1][0] = "std::vector<Point>&"
623+
elif decl[0] == "cv.QRCodeDetector.decode" or decl[0] == "cv.decodeQRCode":
624+
pts_arg = decl[3][1]
625+
if pts_arg[0] == "InputArray" and pts_arg[1] == "points":
626+
decl[3][1][0] = "const std::vector<Point>&"
627+
return decl
628+
629+
615630
#
616631
# TEMPLATES
617632
#
@@ -2423,6 +2438,7 @@ def get_callback(self, name):
24232438
return None
24242439

24252440
def add_decl(self, module, decl):
2441+
decl = decl_patch(module, decl)
24262442
if decl[0] == "cv.String.String" or decl[0] == 'cv.Exception.~Exception':
24272443
return
24282444
if decl[0] == "cv.Algorithm":

0 commit comments

Comments
 (0)