JS bingings fix for QR code detector.

pull/23769/head
Alexander Smorkalov 1 year ago
parent e60a7c0d49
commit 843daca26e
  1. 43
      modules/js/generator/embindgen.py
  2. 4
      platforms/js/opencv_js.config.py

@ -236,6 +236,11 @@ class ArgInfo(object):
self.tp = "std::vector<cv::Mat>&"
elif self.inputarg:
self.tp = "const std::vector<cv::Mat>&"
if self.tp == "vector_string":
if self.outputarg:
self.tp = "std::vector<std::string>&"
elif self.inputarg:
self.tp = "const std::vector<std::string>&"
self.tp = handle_vector(self.tp).strip()
if self.const:
self.tp = "const " + self.tp
@ -319,19 +324,31 @@ class JSWrapperGenerator(object):
sys.exit(-1)
self.classes[class_info.name] = class_info
if class_info.bases:
chunks = class_info.bases[0].split('::')
base = '_'.join(chunks)
while base not in self.classes and len(chunks) > 1:
del chunks[-2]
def resolve_class_inheritance(self):
new_classes = {}
for name, class_info in self.classes.items():
if not hasattr(class_info, 'bases'):
new_classes[name] = class_info
continue # not class
if class_info.bases:
chunks = class_info.bases[0].split('::')
base = '_'.join(chunks)
if base not in self.classes:
print("Generator error: unable to resolve base %s for %s"
% (class_info.bases[0], class_info.name))
sys.exit(-1)
else:
class_info.bases[0] = "::".join(chunks)
class_info.isalgorithm |= self.classes[base].isalgorithm
while base not in self.classes and len(chunks) > 1:
del chunks[-2]
base = '_'.join(chunks)
if base not in self.classes:
print("Generator error: unable to resolve base %s for %s"
% (class_info.bases[0], class_info.name))
sys.exit(-1)
else:
class_info.bases[0] = "::".join(chunks)
class_info.isalgorithm |= self.classes[base].isalgorithm
new_classes[name] = class_info
self.classes = new_classes
def split_decl_name(self, name):
chunks = name.split('.')
@ -759,6 +776,8 @@ class JSWrapperGenerator(object):
else: # class/global function
self.add_func(decl)
self.resolve_class_inheritance()
# step 2: generate bindings
# Global functions
for ns_name, ns in sorted(self.namespaces.items()):

@ -113,8 +113,8 @@ objdetect = {'': ['groupRectangles', 'getPredefinedDictionary', 'extendDictionar
'drawDetectedDiamonds'],
'HOGDescriptor': ['load', 'HOGDescriptor', 'getDefaultPeopleDetector', 'getDaimlerPeopleDetector', 'setSVMDetector', 'detectMultiScale'],
'CascadeClassifier': ['load', 'detectMultiScale2', 'CascadeClassifier', 'detectMultiScale3', 'empty', 'detectMultiScale'],
'QRCodeDetector': ['QRCodeDetector', 'decode', 'decodeCurved', 'detect', 'detectAndDecode', 'detectMulti', 'setEpsX', 'setEpsY'],
# aruco namespace
'GraphicalCodeDetector': ['decode', 'detect', 'detectAndDecode', 'detectMulti', 'decodeMulti', 'detectAndDecodeMulti'],
'QRCodeDetector': ['QRCodeDetector', 'decode', 'detect', 'detectAndDecode', 'detectMulti', 'decodeMulti', 'detectAndDecodeMulti', 'decodeCurved', 'detectAndDecodeCurved', 'setEpsX', 'setEpsY'],
'aruco_PredefinedDictionaryType': [],
'aruco_Dictionary': ['Dictionary', 'getDistanceToId', 'generateImageMarker', 'getByteListFromBits', 'getBitsFromByteList'],
'aruco_Board': ['Board', 'matchImagePoints', 'generateImage'],

Loading…
Cancel
Save