JS bingings fix for QR code detector.

This commit is contained in:
Alexander Smorkalov 2023-06-09 16:06:30 +03:00
parent e60a7c0d49
commit 843daca26e
2 changed files with 33 additions and 14 deletions

View File

@ -236,6 +236,11 @@ class ArgInfo(object):
self.tp = "std::vector<cv::Mat>&" self.tp = "std::vector<cv::Mat>&"
elif self.inputarg: elif self.inputarg:
self.tp = "const std::vector<cv::Mat>&" 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() self.tp = handle_vector(self.tp).strip()
if self.const: if self.const:
self.tp = "const " + self.tp self.tp = "const " + self.tp
@ -319,6 +324,14 @@ class JSWrapperGenerator(object):
sys.exit(-1) sys.exit(-1)
self.classes[class_info.name] = class_info self.classes[class_info.name] = class_info
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: if class_info.bases:
chunks = class_info.bases[0].split('::') chunks = class_info.bases[0].split('::')
base = '_'.join(chunks) base = '_'.join(chunks)
@ -333,6 +346,10 @@ class JSWrapperGenerator(object):
class_info.bases[0] = "::".join(chunks) class_info.bases[0] = "::".join(chunks)
class_info.isalgorithm |= self.classes[base].isalgorithm class_info.isalgorithm |= self.classes[base].isalgorithm
new_classes[name] = class_info
self.classes = new_classes
def split_decl_name(self, name): def split_decl_name(self, name):
chunks = name.split('.') chunks = name.split('.')
namespace = chunks[:-1] namespace = chunks[:-1]
@ -759,6 +776,8 @@ class JSWrapperGenerator(object):
else: # class/global function else: # class/global function
self.add_func(decl) self.add_func(decl)
self.resolve_class_inheritance()
# step 2: generate bindings # step 2: generate bindings
# Global functions # Global functions
for ns_name, ns in sorted(self.namespaces.items()): for ns_name, ns in sorted(self.namespaces.items()):

View File

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