Sink.add_arguments(parser) params, args, pipeline_params, do_display, db_params, db = read_arguments(parser, argv[1:]) model_ids = [] object_ids = set() for object_id in params['object_ids']: for model_id in models.find_model_for_object(db, object_id, 'MMOD'): model_ids.append(str(model_id)) object_ids.add(object_id) model_documents = DbDocuments(db_params, model_ids) # TODO handle this properly... ecto_ros.init(argv, "mmod_testing", False)#not anonymous. source = Source.parse_arguments(params['source']) sink = Sink.parse_arguments(args, db, db_params, object_ids) #hook up the tester mmod_tester = MModTester(thresh_match=0.93,color_filter_thresh=0.8,skip_x=8,skip_y=8, model_documents=model_documents) # Connect the detector to the source pyr_img = mmod.Pyramid(n_levels=3) pyr_depth = mmod.Pyramid(n_levels=3) for key in source.outputs.iterkeys(): if key in mmod_tester.inputs.keys(): if key == 'image': plasm.connect([ source[key] >> pyr_img['image'], pyr_img['level_' + str(N_LEVEL_MAX-1)] >> mmod_tester[key] ])
from object_recognition.common.filters.masker import Masker from object_recognition.common.io.sink import Sink from object_recognition.common.io.source import Source from object_recognition.tod.detector import TodDetector DEBUG = False DISPLAY = True PoseArrayPub = ecto_geometry_msgs.Publisher_PoseArray ######################################################################################################################## if __name__ == '__main__': plasm = ecto.Plasm() source = Source(plasm) masker = Masker(plasm) sink = Sink(plasm) parser = ArgumentParser() # add arguments for the source source.add_arguments(parser) # add arguments for the sink sink.add_arguments(parser) parser.add_argument("-b", "--bag", dest="bag", help="The bag to analyze") parser.add_argument("-c", "--config_file", dest="config_file", help='the file containing the configuration as JSON. It should contain the following fields.\n' '"feature_descriptor": with parameters for "combination", "feature" and "descriptor".\n' '"db": parameters about the db: "type", "url".\n'
#!/usr/bin/env python from object_recognition.common.io.source import _assert_source_interface from object_recognition.common.io.source import Source import argparse parser = argparse.ArgumentParser(description='An source reader.') Source.add_arguments(parser) parser.print_help() #test default args args = parser.parse_args() source = Source.parse_arguments(args) _assert_source_interface(source) print source.__class__.__name__ #assert 'KinectReader' == source.__class__.__name__ #test a bad bag args = parser.parse_args(['--ros_bag','non_existant.bag']) try: source = Source.parse_arguments(args) except RuntimeError,e: print str(e) assert 'non_existant.bag does not exist.' in str(e) #test an existing bag with open('a_test.bag','w') as f: f.write('\ntest\n') args = parser.parse_args(['--ros_bag','a_test.bag']) #note that the bag hasn't been opened here.
params, args, pipeline_params, do_display, db_params, db = read_arguments( parser, argv[1:]) model_ids = [] object_ids = set() for object_id in params['object_ids']: for model_id in models.find_model_for_object(db, object_id, 'MMOD'): model_ids.append(str(model_id)) object_ids.add(object_id) model_documents = DbDocuments(db_params, model_ids) # TODO handle this properly... ecto_ros.init(argv, "mmod_testing", False) #not anonymous. source = Source.parse_arguments(params['source']) sink = Sink.parse_arguments(args, db, db_params, object_ids) #hook up the tester mmod_tester = MModTester(thresh_match=0.93, color_filter_thresh=0.8, skip_x=8, skip_y=8, model_documents=model_documents) # Connect the detector to the source pyr_img = mmod.Pyramid(n_levels=3) pyr_depth = mmod.Pyramid(n_levels=3) for key in source.outputs.iterkeys(): if key in mmod_tester.inputs.keys():
def source(self, source_params): return Source.parse_arguments(source_params)