Beispiel #1
0
 def detector(self, *args, **kwargs):
     visualize = kwargs.pop('visualize', False)
     submethod = kwargs.pop('submethod')
     parameters = kwargs.pop('parameters')
     object_ids = parameters['object_ids']
     object_db = ObjectDb(parameters['db'])
     model_documents = Models(object_db, object_ids, self.type_name(), json_helper.dict_to_cpp_json_str(submethod))
     model_file = parameters['extra'].get('model_file')
     return object_recognition_by_parts_cells.Detector(model_file=model_file, visualize=visualize)
Beispiel #2
0
 def detector(self, *args, **kwargs):
     visualize = kwargs.pop('visualize', False)
     submethod = kwargs.pop('subtype')
     parameters = kwargs.pop('parameters')
     object_ids = parameters['object_ids']
     object_db = ObjectDb(parameters['db'])
     model_documents = Models(object_db, object_ids, self.type_name(),
                              json_helper.dict_to_cpp_json_str(submethod))
     return PBDDetector(object_db, object_ids, visualize, *args,
                        **parameters['extra'])
Beispiel #3
0
 def detector(self, *args, **kwargs):
     #visualize = args.get('visualize', False)
     submethod = kwargs.get('submethod')
     parameters = kwargs.get('parameters')
     object_ids = parameters['object_ids']
     object_db = ObjectDb(parameters['db'])
     model_documents = Models(object_db, object_ids, self.type_name(),
                              json_helper.dict_to_cpp_json_str(submethod))
     threshold = parameters.get('threshold', 90)
     return ecto_linemod.Detector(model_documents=model_documents,
                                  db=object_db,
                                  threshold=threshold)
Beispiel #4
0
 def detector(self, *args, **kwargs):
     visualize = kwargs.pop('visualize', False)
     submethod = kwargs.pop('submethod')
     parameters = kwargs.pop('parameters')
     object_ids = parameters['object_ids']
     object_db = ObjectDb(parameters['db'])
     model_documents = Models(object_db, object_ids, self.type_name(),
                              json_helper.dict_to_cpp_json_str(submethod))
     registrationMaskFilename = parameters.get('registrationMaskFilename')
     return transparent_objects_cells.Detector(
         model_documents=model_documents,
         object_db=object_db,
         registrationMaskFilename=registrationMaskFilename,
         visualize=visualize)
Beispiel #5
0
def handles_training(req):
    parser = create_parser(do_training=True)

    #args = parser.parse_args()
    args = parser.parse_args(['-c', req.cmd])
    args = parser.parse_args(['--config_file', req.path])
    ork_params, _args = read_arguments(args)

    for _pipeline_id, pipeline_param in ork_params.iteritems():
        pipeline_class = find_class([ pipeline_param['module'] ], pipeline_param['type'] )
        if not pipeline_class:
            raise RuntimeError('Invalid pipeline name: %s\nMake sure that the pipeline type is defined by a '
                               'TrainingPipeline class, in the name class function.' % pipeline_param['type'])

        db_params_raw = pipeline_param['parameters'].get('json_db', {})
        db_params = db_params_raw
        object_ids = interpret_object_ids(db_params, pipeline_param.get('parameters', {}).get('json_object_ids', []))
        print('Training %d objects.' % len(object_ids))
        for object_id in object_ids:
            print('computing object_id: %s' % object_id)
            object_id = object_id.encode('ascii')

            ork_params_sub = {}
            ork_params_sub[_pipeline_id] = pipeline_param
            ork_params_sub[_pipeline_id]['parameters']['object_id'] = object_id
            plasm = create_plasm(ork_params_sub)
            plasm.execute()

        # Make sure the views exist
        object_db = ObjectDb(db_params)
        db_params = ObjectDbParameters(db_params)
        if db_params.type == ObjectDbTypes.COUCHDB:
            import couchdb
            import json
            dic = json.loads(db_params_raw)
            couch = couchdb.Server(dic['root'])
            init_object_databases(couch)
	
    return training_srvResponse()
Beispiel #6
0
    options = parser.parse_args()

    return options


if __name__ == '__main__':
    options = parse_args()

    plasm = ecto.Plasm()

    db_params = ObjectDbParameters({
        'type': 'CouchDB',
        'root': 'http://bwl.willowgarage.com:5984',
        'collection': 'object_recognition'
    })
    object_db = ObjectDb(db_params)

    #setup the input source, grayscale conversion
    from ecto_openni import VGA_RES, FPS_30
    source = create_source('image_pipeline',
                           'OpenNISource',
                           image_mode=VGA_RES,
                           image_fps=FPS_30)

    print LinemodDetectionPipeline.type_name()
    object_ids = ['whoolite', 'tilex']
    model_documents = Models(object_db, object_ids,
                             LinemodDetectionPipeline.type_name(),
                             json_helper.dict_to_cpp_json_str({}))
    print len(model_documents)
    detector = Detector(model_documents=model_documents,
Beispiel #7
0
from object_recognition_core.db.tools import db_params_to_db
from object_recognition_core.db.object_db import core_db_types

print 'Existing core types: ' + str(core_db_types())

str_to_enum = {'CouchDB': ObjectDbTypes.COUCHDB, 'filesystem': ObjectDbTypes.FILESYSTEM, 'empty': ObjectDbTypes.EMPTY }

# test default parameters
for db_params_raw in [{'type': 'CouchDB', 'root': 'http://localhost:5984', 'collection': 'object_recognition'},
                      {'path': '/tmp', 'type': 'filesystem', 'collection': 'object_recognition'},
                      {'type': 'empty'}]:
    type_str = db_params_raw['type']
    print 'starting type ' + type_str
    db_params = ObjectDbParameters(db_params_raw)

    db = ObjectDb(db_params)
    db_params_new = db.parameters().raw

    for dic1, dic2 in [(db_params_raw, db_params_new), (db_params_new, db_params_raw)]:
        for k, v in dic1.items():
            if (k not in dic2) or (k in dic2 and dic2[k] != v):
                raise RuntimeError('Key "%s" in %s but not in %s' % (str(k), str(dic1), str(dic2)))

    if str_to_enum[type_str] != db_params.type:
        raise RuntimeError('The "type" argument in db_params are wrong for db of type %s' % type_str)

    print 'ending type ' + type_str

    # test that we can convert a JSON string to an ObjectDbParameters type
    db_params_to_db(db_params)