def main(args): sec = "humandetector" args = sys.argv[1:] option_dict = configparse.parse_args_to_param_dict(args, sec) rospy.init_node('HumanDetector') #READ PARAMETERS: host = option_dict.get_option(sec, 'host') port = option_dict.get_option(sec, 'port') source = option_dict.get_option(sec, 'video_source') freq = option_dict.get_option(sec, 'update_frequency') # Transform is fixed transform = [[0, 0, 0.63]] detector = HumanDetector(host, port, freq, source, transform) detector.connect() detector.run() cv.DestroyAllWindows()
return self.vid_mem_reader.get_latest_image()[0] def usage(): print "You should add the configuration options on the command line." print "" print "Usage: ", sys.argv[0], " host=<controller_host> port=<controller_port> updatefreq=<update frequency>" print "" if __name__ == "__main__": if len(sys.argv) < 3: usage() exit() sec = "snapshotsaver" #section in config_dict args = sys.argv[1:] config_dict = configparse.parse_args_to_param_dict(args, sec) update_frequency = config_dict.get_option(sec, "updatefreq") controller_ip = config_dict.get_option(sec, "host") controller_port = config_dict.get_option(sec, "port") destination = config_dict.get_option(sec, "destination") use_verbose = config_dict.get_option(sec, "verbose", "False") prefix = config_dict.get_option(sec, "prefix", "") sect = config_dict.get_section(sec) print sect if not (update_frequency and controller_ip and controller_port): usage() exit() logging.getLogger('Borg.Brain').addHandler(util.loggingextra.ScreenOutput())
fp = open(location_file, "w") fp.write("name,x,y,angle\n") else: fp = open(location_file, "a") fp.write("%s,%f,%f,%f\n" % (name, odo['x'], odo['y'], odo['angle'])) fp.close() print "File saved" if __name__ == "__main__": logging.getLogger('Borg.Brain').addHandler(loggingextra.ScreenOutput()) logging.getLogger('Borg.Brain').setLevel(logging.INFO) #PARSE COMMAND LINE ARGUMENTS section = "remote" # in config_dict arguments = sys.argv[1:] config_dict = configparse.parse_args_to_param_dict(arguments, section) #READ PARAMETERS: controller_ip = config_dict.get_option(section, 'host') controller_port = config_dict.get_option(section, 'port') #START: remote = Remote(controller_ip, controller_port) remote.connect() remote.train() try: remote.run() finally: remote.stop()
merged = segmentations[0] for segments in segmentations: for y in range(len(segments)): for x in range(len(segments[0])): if segments[y][x] < merged[y][x]: merged[y][x] = segments[y][x] return merged if __name__ == "__main__": """ run obstacledetector as an behavior """ sec = "obstacledetector" #section in config_dict args = sys.argv[1:] option_dict = configparse.parse_args_to_param_dict(args, sec) logging.getLogger('Borg.Brain').addHandler( util.loggingextra.ScreenOutput()) logging.getLogger('Borg.Brain').setLevel(logging.INFO) #READ PARAMETERS: controller_ip = option_dict.get_option(sec, 'host') controller_port = option_dict.get_option(sec, 'port') source = option_dict.get_option(sec, 'video_source') print "OBSTACLE AVOIDANCE STARTING AT %s : %s" % (controller_ip, controller_port) detector = ObstacleDetector(controller_ip, controller_port, source=source) detector.connect() detector.run()
if not os.path.exists(location_file): fp = open(location_file, "w") fp.write("name,x,y,angle\n") else: fp = open(location_file, "a") fp.write("%s,%f,%f,%f\n" % (name, odo['x'], odo['y'], odo['angle'])) fp.close() print "File saved" if __name__ == "__main__": logging.getLogger('Borg.Brain').addHandler(loggingextra.ScreenOutput()) logging.getLogger('Borg.Brain').setLevel(logging.INFO) #PARSE COMMAND LINE ARGUMENTS section = "remote" # in config_dict arguments = sys.argv[1:] config_dict = configparse.parse_args_to_param_dict(arguments, section) #READ PARAMETERS: controller_ip = config_dict.get_option(section,'host') controller_port = config_dict.get_option(section,'port') #START: remote = Remote(controller_ip, controller_port) remote.connect() remote.train() try: remote.run() finally: remote.stop()