def ObjectDb(db_params): """ Returns the ObjectDb for the given db_params given as a dictionary It crawls the object_recognition_core module or any other module in order to find the ObjectDb you are looking for :param db_params: ObjectDbParameters defining a DB, or json string or dict """ if (isinstance(db_params, ObjectDbParameters)): db_params_raw = db_params.raw object_db_params = db_params elif (isinstance(db_params, str)): db_params_raw = json.loads(db_params) object_db_params = ObjectDbParameters(db_params) else: db_params_raw = db_params object_db_params = ObjectDbParameters(db_params) # check if it is a conventional DB from object_recognition_core db_type = db_params_raw.get('type', None) if db_type.lower() in core_db_types(): from object_recognition_core.boost.interface import ObjectDb as ObjectDbCpp return ObjectDbCpp(object_db_params) # otherwise, look for the possible modules for that DB type module = db_params_raw.get('module', None) if not module: raise RuntimeError("The 'module' property is not set. It is required to find the DB object") for db_factory in find_classes([module], [ObjectDbFactory]): if db_factory.__name__ == db_type: return db_factory.object_db(db_params_raw)
def ObjectDb(db_params): """ Returns the ObjectDb for the given db_params given as a dictionary It crawls the object_recognition_core module or any other module in order to find the ObjectDb you are looking for :param db_params: ObjectDbParameters defining a DB, or json string or dict """ if (isinstance(db_params, ObjectDbParameters)): db_params_raw = db_params.raw object_db_params = db_params elif (isinstance(db_params, str)): db_params_raw = json.loads(db_params) object_db_params = ObjectDbParameters(db_params) else: db_params_raw = db_params object_db_params = ObjectDbParameters(db_params) # check if it is a conventional DB from object_recognition_core db_type = db_params_raw.get('type', None) if db_type.lower() in core_db_types(): from object_recognition_core.boost.interface import ObjectDb as ObjectDbCpp return ObjectDbCpp(object_db_params) # otherwise, look for the possible modules for that DB type module = db_params_raw.get('module', None) if not module: raise RuntimeError( "The 'module' property is not set. It is required to find the DB object" ) for db_factory in find_classes([module], [ObjectDbFactory]): if db_factory.__name__ == db_type: return db_factory.object_db(db_params_raw)
def config_yaml_for_ecto_cells(class_type): """ Function returning an array of doc strings for each cell of class `class_type` in object_recognition :param class_type: one of 'detection_pipeline', 'training_pipeline', 'source', 'sink' """ from object_recognition_core.io.sink import SinkBase from object_recognition_core.io.source import SourceBase from object_recognition_core.io.voter import VoterBase from object_recognition_core.pipelines.detection import DetectorBase from object_recognition_core.pipelines.training import TrainerBase supported_classes = { 'detection_pipeline': DetectorBase, 'training_pipeline': TrainerBase, 'source': SourceBase, 'sink': SinkBase } if class_type not in supported_classes: raise RuntimeError('Class type not support: %s. Accepted are: %s' % (class_type, str(supported_classes.keys()))) modules = set() # go over the modules on the PYTHONPATH and only keep the ones that start with object_recognition if 'PYTHONPATH' not in os.environ: raise RuntimeError('You need a PYTHONPATH to use that script') for path in os.environ['PYTHONPATH'].split(':'): if not os.path.isdir(path): continue for name in os.listdir(path): if os.path.isdir(os.path.join( path, name)) and (name.startswith('object_recognition') or name.startswith('ork')): modules.add(name) # find all the objects of the right type classes = find_classes(modules, [supported_classes[class_type]]) # create a string with the config documentation res_list = [] class_number = 0 for class_object in classes: res = config_yaml_for_ecto_cell(class_object, '%s_%s' % (class_type, class_number)) class_number += 1 res_list.append(res) return res_list
def config_yaml_for_ecto_cells(class_type): """ Function returning an array of doc strings for each cell of class `class_type` in object_recognition :param class_type: one of 'detection_pipeline', 'training_pipeline', 'source', 'sink' """ from object_recognition_core.io.sink import SinkBase from object_recognition_core.io.source import SourceBase from object_recognition_core.io.voter import VoterBase from object_recognition_core.pipelines.detection import DetectorBase from object_recognition_core.pipelines.training import TrainerBase supported_classes = {'detection_pipeline': DetectorBase, 'training_pipeline': TrainerBase, 'source': SourceBase, 'sink': SinkBase} if class_type not in supported_classes: raise RuntimeError('Class type not support: %s. Accepted are: %s' % (class_type, str(supported_classes.keys()))) modules = set() # go over the modules on the PYTHONPATH and only keep the ones that start with object_recognition if 'PYTHONPATH' not in os.environ: raise RuntimeError('You need a PYTHONPATH to use that script') for path in os.environ['PYTHONPATH'].split(':'): if not os.path.isdir(path): continue for name in os.listdir(path): if os.path.isdir(os.path.join(path,name)) and (name.startswith('object_recognition') or name.startswith('ork')): modules.add(name) # find all the objects of the right type classes = find_classes(modules, [supported_classes[class_type]]) # create a string with the config documentation res_list = [] class_number = 0 for class_object in classes: res = config_yaml_for_ecto_cell(class_object, '%s_%s' % (class_type, class_number)) class_number += 1 res_list.append(res) return res_list
raise RuntimeError('Class type not support: %s. Accepted are: %s' % (args.class_type, str(supported_classes.keys()))) modules = set() # go over the modules on the PYTHONPATH and only keep the ones that start with object_recognition if 'PYTHONPATH' not in os.environ: raise RuntimeError('You need a PYTHONPATH to use that script') for path in os.environ['PYTHONPATH'].split(':'): if not os.path.isdir(path): continue for name in os.listdir(path): if os.path.isdir(os.path.join(path,name)) and (name.startswith('object_recognition') or name.startswith('ork')): modules.add(name) # find all the objects of the right type print modules classes = find_classes(modules, [supported_classes[args.class_type]]) print classes # create a string with the config documentation res = '' """ class_number = 0 for _class_name, class_object in classes.items(): res += '[%s%s]\n' % (args.class_type, class_number) res += indent_yaml(class_object.config_doc_default()) if yaml.load(class_object.config_doc()): res += indent_yaml(class_object.config_doc()) class_number += 1 res += '\n' """ print res[:-1]