def single_image_histograms(): p = dtu.require_resource('frame0002.jpg') image_cv = dtu.image_cv_from_jpg_fn(p) res = go(image_cv) outd = dtu.get_output_dir_for_test() dtu.write_bgr_images_as_jpgs(res, outd)
def get_log_if_not_exists(logs, log_name): """" Returns the path to the log. """ downloads = get_duckietown_local_log_downloads() if log_name.endswith('.bag'): msg = 'get_log_if_not_exists() wants a log name, not a bag file' raise ValueError(msg) if log_name in logs and (logs[log_name].filename is not None): where = logs[log_name].filename logger.info('We already have %s locally at %s' % (log_name, where)) return where else: logger.info('We do not have %s locally.' % log_name) filename = os.path.join(downloads, log_name + '.bag') if os.path.exists(filename): logger.info('It was already downloaded as %s' % filename) return filename resource = log_name + '.bag' require_resource(resource, destination=filename) return filename
def get_easy_logs_db_cloud(): cloud_file = require_resource('cloud.yaml') # cloud_file = os.path.join(get_ros_package_path('easy_logs'), 'cloud.yaml') # if not os.path.exists(cloud_file): # url = "https://www.dropbox.com/s/vdl1ej8fihggide/duckietown-cloud.yaml?dl=1" # download_url_to_file(url, cloud_file) logger.info('Loading cloud DB %s' % friendly_path(cloud_file)) logs = yaml_load_file(cloud_file) logs = OrderedDict(logs) logger.info('Loaded cloud DB with %d entries.' % len(logs)) return EasyLogsDB(logs)
def get_logs_cloud(): cloud_file = dtu.require_resource('cloud2.yaml') with dtu.timeit_wall("loading DB"): dtu.logger.info('Loading cloud DB %s' % dtu.friendly_path(cloud_file)) with dtu.timeit_wall('YAML load file'): data = dtu.yaml_load_file(cloud_file, plain_yaml=True) # with dtu.timeit_wall('plain'): # data = open(cloud_file).read() # import yaml # yaml.load(data) dtu.logger.debug('Conversion') logs = logs_from_yaml(data) logs = OrderedDict(logs) dtu.logger.info('Loaded cloud DB with %d entries.' % len(logs)) return logs
def single_image1(): p = dtu.require_resource('frame0002.jpg') image_cv = dtu.image_cv_from_jpg_fn(p) line_detector_name = 'baseline' image_prep_name = 'baseline' lane_filter_name = 'baseline' anti_instagram_name = 'baseline' robot_name = dtu.DuckietownConstants.ROBOT_NAME_FOR_TESTS gp = GroundProjection(robot_name) res, _stats = run_pipeline(image_cv, gp, line_detector_name=line_detector_name, image_prep_name=image_prep_name, lane_filter_name=lane_filter_name, anti_instagram_name=anti_instagram_name, all_details=False, ground_truth=None) outd = dtu.get_output_dir_for_test() dtu.write_jpgs_to_dir(res, outd)
def anti_instagram_annotations_test(): out_base = dtu.get_output_dir_for_test() # out_base = 'anti_instagram_annotations_test' zipname = dtu.require_resource('ii-datasets.zip') dirname = os.path.dirname(zipname) base = os.path.join(dirname, 'ii-datasets') cmd = ['unzip', '-o', zipname] cwd = dirname dtu.system_cmd_result(cwd, cmd, display_stdout=False, display_stderr=False, raise_on_error=True) if not os.path.exists(base): msg = 'Could not find expected unzipped directory:\n %s' % base raise Exception(msg) anti_instagram_annotations_test(base, out_base)