def get_cv2_object(name): if name.startswith("cv2."): name = name[4:] if name.startswith("cv."): name = name[3:] if name == "Algorithm": return cv2.Algorithm__create("Feature2D.ORB"), name elif name == "FeatureDetector": return cv2.FeatureDetector_create("ORB"), name elif name == "DescriptorExtractor": return cv2.DescriptorExtractor_create("ORB"), name elif name == "BackgroundSubtractor": return cv2.BackgroundSubtractorMOG(), name elif name == "StatModel": return cv2.KNearest(), name else: return getattr(cv2, name)(), name
def get_cv2_object(name): if name.startswith("cv2."): name = name[4:] if name.startswith("cv."): name = name[3:] if name == "Algorithm": return cv2.Algorithm__create("Feature2D.ORB"), name elif name == "FeatureDetector": return cv2.FeatureDetector_create("ORB"), name elif name == "DescriptorExtractor": return cv2.DescriptorExtractor_create("ORB"), name elif name == "BackgroundSubtractor": return cv2.createBackgroundSubtractorMOG(), name elif name == "StatModel": return cv2.KNearest(), name else: try: obj = getattr(cv2, name)() except AttributeError: obj = getattr(cv2, "create" + name)() return obj, name