def parse_args(): import argparse parser = argparse.ArgumentParser(description='Train MyAlgorithm on views from the database.') parser.add_argument('objects', metavar='OBJECT', type=str, nargs='+', help='Object ids to train.') dbtools.add_db_options(parser) args = parser.parse_args() return args
def parse_args(): import argparse parser = argparse.ArgumentParser(description='Train MyAlgorithm on views from the database.') parser.add_argument('objects', metavar='OBJECT', type=str, nargs='*', help='Object ids to train.') parser.add_argument('--all', dest='compute_all', action='store_const', const=True, default=False, help='Compute meshes for all possible sessions.') dbtools.add_db_options(parser) args = parser.parse_args() return args
def parse_args(): parser = argparse.ArgumentParser(description='''Uploads a bag, with an object description to the db. ''') parser.add_argument('-i', '--input', metavar='BAG_FILE', dest='bag', type=str, default='', help='A bagfile to upload.') parser.add_argument('-n', '--object_name', metavar='OBJECT_NAME', dest='object_name', type=str, default='') parser.add_argument('-d', '--description', metavar='DESCRIPTION', dest='description', type=str, default='') parser.add_argument('-a', '--author', metavar='AUTHOR_NAME', dest='author_name', type=str, default='') parser.add_argument('-e', '--email', metavar='EMAIL_ADDRESS', dest='author_email', type=str, default='') parser.add_argument('tags', metavar='TAGS', type=str, nargs='+', help='Tags to add to object description.') add_db_options(parser) args = parser.parse_args() if len(args.bag) < 1: parser.print_help() sys.exit(1) return args
def read_arguments(parser=None, argv=sys.argv): """ Returns: params, pipeline_params, db_dict, db params: all the pipeline parameters specified in the config file or command line pipeline_params: an array of parameters for each pipeline db_dict: the dictionary of the db parameters db: a db object created from those parameters """ if parser is None: parser = ObjectRecognitionParser() parser.add_argument('-c', '--config_file', help='Config file') parser.add_argument('--object_ids', help='If set, it overrides the list of object_ids in the config file') parser.add_argument('--object_names', help='If set, it overrides the list of object names in the config file') parser.add_argument('--visualize', help='If set, it will display some windows with temporary results', default=False, action='store_true') dbtools.add_db_options(parser) try: import ecto_ros ecto_ros.strip_ros_args(argv) except: pass if '--help' in sys.argv or '-h' in sys.argv: args = parser.parse_args() else: args = parser.parse_args()#args=argv) # define the input if args.config_file is None or not os.path.exists(args.config_file): print >>sys.stderr, "The option file does not exist. --help for usage." sys.exit(-1) params = yaml.load(open(args.config_file)) # read some parameters db_params = args_to_db_params(args, params.get('db', {})) # initialize the DB db = dbtools.db_params_to_db(db_params) # read the object_ids object_ids = set() for obj in (args.__dict__, params): ids = obj.get('object_ids', None) names = obj.get('object_names', None) if 'all' in (ids, names): object_ids = set([ str(x.id) for x in models.Object.all(db) ]) #unicode without the str() break if 'missing' in (ids, names): tmp_object_ids = set([ str(x.id) for x in models.Object.all(db) ]) tmp_object_ids_from_names = set([ str(x.object_id) for x in models.Model.all(db) ]) object_ids.update(tmp_object_ids.difference(tmp_object_ids_from_names)) if ids and ids != 'missing': object_ids.update(ids[1:-1].split(',')) if names and names != 'missing': for object_name in names[1:-1].split(','): object_ids.update([str(x.id) for x in models.objects_by_name(db, object_name)]) # if we got some ids through the command line, just stop here if object_ids: break object_ids = list(object_ids) params['object_ids'] = object_ids pipeline_params = [] for key , value in params.iteritems(): if key.startswith('pipeline'): pipeline_params.append(value) args = vars(args) return params, args, pipeline_params, args['visualize'], db_params
def read_arguments(parser=None, argv=sys.argv): """ Returns: params, pipeline_params, db_dict, db params: all the pipeline parameters specified in the config file or command line pipeline_params: an array of parameters for each pipeline db_dict: the dictionary of the db parameters db: a db object created from those parameters """ if parser is None: parser = ObjectRecognitionParser() parser.add_argument('-c', '--config_file', help='Config file') parser.add_argument( '--object_ids', help='If set, it overrides the list of object_ids in the config file') parser.add_argument( '--object_names', help='If set, it overrides the list of object names in the config file' ) parser.add_argument( '--visualize', help='If set, it will display some windows with temporary results', default=False, action='store_true') dbtools.add_db_options(parser) try: import ecto_ros ecto_ros.strip_ros_args(argv) except: pass if '--help' in sys.argv or '-h' in sys.argv: args = parser.parse_args() else: args = parser.parse_args() #args=argv) # define the input if args.config_file is None or not os.path.exists(args.config_file): print >> sys.stderr, "The option file does not exist. --help for usage." sys.exit(-1) params = yaml.load(open(args.config_file)) # read some parameters db_params = args_to_db_params(args, params.get('db', {})) # initialize the DB db = dbtools.db_params_to_db(db_params) # read the object_ids object_ids = set() for obj in (args.__dict__, params): ids = obj.get('object_ids', None) names = obj.get('object_names', None) if 'all' in (ids, names): object_ids = set([str(x.id) for x in models.Object.all(db) ]) #unicode without the str() break if 'missing' in (ids, names): tmp_object_ids = set([str(x.id) for x in models.Object.all(db)]) tmp_object_ids_from_names = set( [str(x.object_id) for x in models.Model.all(db)]) object_ids.update( tmp_object_ids.difference(tmp_object_ids_from_names)) if ids and ids != 'missing': object_ids.update(ids[1:-1].split(',')) if names and names != 'missing': for object_name in names[1:-1].split(','): object_ids.update([ str(x.id) for x in models.objects_by_name(db, object_name) ]) # if we got some ids through the command line, just stop here if object_ids: break object_ids = list(object_ids) params['object_ids'] = object_ids pipeline_params = [] for key, value in params.iteritems(): if key.startswith('pipeline'): pipeline_params.append(value) args = vars(args) return params, args, pipeline_params, args['visualize'], db_params
plasm.connect([bagreader['info'] >> bagwriter['info_rgb'], bagreader['info'] >> bagwriter['info_depth'], bagreader['rgb'] >> bagwriter['rgb'], bagreader['depth'] >> pcd_msg2depth_msg['cloud'], pcd_msg2depth_msg['image'] >> bagwriter['depth'] ]) sched = ecto.schedulers.Singlethreaded(plasm) sched.execute() return tmp_bag_path if __name__ == '__main__': ecto_ros.init(sys.argv, "ecto_node") parser = ArgumentParser() parser.add_argument('--folder', dest='folder', help='The Folder where all the NIST bags are located', required=True) add_db_options(parser) args = parser.parse_args() # process all the bags in the folder for file_name in os.listdir(args.folder): if not file_name.endswith('.bag'): continue # persist the bad to the DB object_index = int(file_name[7:9]) print '------- %s' % file_name bag_path = convert_bag(args.folder, file_name) print 'uploading file "%s"' % file_name obj = models.Object(object_name=NIST_IDS[object_index],