def __init__(self, ork_params, action_name): # create the plasm that will run the detection self.plasm = create_plasm(ork_params) self.plasm.configure_all() rospy.loginfo('ORK server configured') # the results or the object recognition pipeline self.recognition_result = None topics = ['recognized_object_array'] for sink in ork_params.values(): if 'recognized_object_array_topic' in sink: topics.append(sink['recognized_object_array_topic']) # subscribe to the output of the detection pipeline for topic in topics: rospy.Subscriber(topic, RecognizedObjectArray, self.callback_recognized_object_array) rospy.loginfo('Subscribed to the ' + topic + ' topic.') # look for a cell that contains a cropper to select the ROI self.cropper = None for cell in self.plasm.cells(): if 'crop_enabled' in cell.params: self.cropper = cell # actionlib stuff if action_name and action_name != '""': self.server = actionlib.SimpleActionServer(action_name, ObjectRecognitionAction, self.execute, False) else: self.server = actionlib.SimpleActionServer('recognize_objects', ObjectRecognitionAction, self.execute, False) self.server.start() rospy.loginfo('ORK server started')
def __init__(self, ork_params): # create the plasm that will run the detection self.plasm = create_plasm(ork_params) self.plasm.configure_all() rospy.loginfo('ORK server configured') # the results or the object recognition pipeline self.recognition_result = None topics = ['recognized_object_array'] for sink in ork_params.values(): if 'recognized_object_array_topic' in sink: topics.append(sink['recognized_object_array_topic']) # subscribe to the output of the detection pipeline for topic in topics: rospy.Subscriber(topic, RecognizedObjectArray, self.callback_recognized_object_array) rospy.loginfo('Subscribed to the ' + topic + ' topic.') # look for a cell that contains a cropper to select the ROI self.cropper = None for cell in self.plasm.cells(): if 'crop_enabled' in cell.params: self.cropper = cell # actionlib stuff self.server = actionlib.SimpleActionServer('recognize_objects', ObjectRecognitionAction, self.execute, False) self.server.start() rospy.loginfo('ORK server started')
def execute_detection(cmd,path): parser = create_parser() # add ecto options scheduler_options(parser) pid = os.getpid() print("pid = ", pid) args = parser.parse_args(['-c', cmd]) args = parser.parse_args(['--config_file', path]) # create the plasm that will run the detection # args = parser.parse_args() ork_params, _args = read_arguments(args) plasm = create_plasm(ork_params) # run the detection plasm run_plasm(args, plasm) print "Exit Finished"
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()
#!/usr/bin/env python """ This script tests whether a detection pipeline can be created given a config file. It is not meant to be run as a test of object_recognition but as a test for and by each pipeline independently. """ from ecto.opts import scheduler_options from object_recognition_core.pipelines.plasm import create_plasm from object_recognition_core.utils.training_detection_args import create_parser, read_arguments if __name__ == '__main__': # create an ORK parser parser = create_parser() # add ecto options scheduler_options(parser) # read the config file args = parser.parse_args() ork_params, args = read_arguments(args) # override the database parameters for cell_name, parameters in ork_params.items(): if 'parameters' in parameters and 'object_ids' in parameters[ 'parameters']: parameters['parameters']['object_ids'] = '[]' # create the big plasm plasm = create_plasm(ork_params)
#!/usr/bin/env python """ This script tests whether a detection pipeline can be created given a config file. It is not meant to be run as a test of object_recognition but as a test for and by each pipeline independently. """ from ecto.opts import scheduler_options from object_recognition_core.pipelines.plasm import create_plasm from object_recognition_core.utils.training_detection_args import create_parser, read_arguments if __name__ == '__main__': # create an ORK parser parser = create_parser() # add ecto options scheduler_options(parser) # read the config file args = parser.parse_args() ork_params, args = read_arguments(args) # override the database parameters for cell_name, parameters in ork_params.items(): if 'parameters' in parameters and 'object_ids' in parameters['parameters']: parameters['parameters']['object_ids'] = '[]' # create the big plasm plasm = create_plasm(ork_params)