Example #1
0
    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] ])
Example #2
0
    # 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', '{')
#!/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.
Example #4
0
    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)
 def source(self, source_params):
     return Source.parse_arguments(source_params)