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] ]) elif key == 'depth': plasm.connect([ source[key] >> pyr_depth['image'], pyr_depth['level_' + str(N_LEVEL_MAX-1)] >> mmod_tester[key] ],
# 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' '"objects_ids": the list of object to process, e.g. ["amys_country_cheddar_bowl",' '"band_aid_plastic_strips"]\n' '"search": the "type" of the search structure, the "radius" and/or "ratio" for the ratio test.\n' ) # parse the arguments source.parse_arguments(parser) sink.parse_arguments(parser) options = parser.parse_args() # define the input if options.config_file is None or not os.path.exists(options.config_file): raise 'option file does not exist' # Get the parameters from the file json_params = json.loads(str(open(options.config_file).read())) feature_descriptor_params = eval(str(json_params['feature_descriptor']).replace("'", '"').replace('u"', '"').\ replace('{u', '{')) db_json_params = str(json_params['db']).replace("'", '"').replace('u"', '"').replace('{u', '{') object_ids = eval(str(json_params['object_ids']).replace("'", '"').replace('u"', '"').replace('{u', '{')) guess_json_params = str(json_params['guess']).replace("'", '"').replace('u"', '"').replace('{u', '{') search_json_params = str(json_params['search']).replace("'", '"').replace('u"', '"').replace('{u', '{')
def sink(self, sink_params, object_ids, db_params): return Sink.parse_arguments(sink_params, db_params, object_ids)
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([