Exemplo n.º 1
0
def load_camera_info_3(robot):
    # Load camera information
    filename = (os.environ['DUCKIEFLEET_ROOT'] +
                "/calibrations/camera_intrinsic/" + robot + ".yaml")
    if not os.path.isfile(filename):
        dtu.logger.warn(
            "no intrinsic calibration parameters for {}, trying default".
            format(robot))
        filename = (os.environ['DUCKIEFLEET_ROOT'] +
                    "/calibrations/camera_intrinsic/default.yaml")
        if not os.path.isfile(filename):
            dtu.logger.error("can't find default either, something's wrong")
    calib_data = dtu.yaml_load_file(filename)
    cam_info = CameraInfo()
    cam_info.width = calib_data['image_width']
    cam_info.height = calib_data['image_height']
    cam_info.K = calib_data['camera_matrix']['data']
    cam_info.D = calib_data['distortion_coefficients']['data']
    cam_info.R = calib_data['rectification_matrix']['data']
    cam_info.P = calib_data['projection_matrix']['data']
    cam_info.distortion_model = calib_data['distortion_model']
    dtu.logger.info(
        "Loaded camera calibration parameters for {} from {}".format(
            robot, os.path.basename(filename)))
    return cam_info
Exemplo n.º 2
0
def get_camera_info_for_robot(robot_name):
    """
        Returns a CameraInfo object for the given robot.
        This is in a good format to pass to PinholeCameraModel:
            self.pcm = PinholeCameraModel()
            self.pcm.fromCameraInfo(self.ci)
        The fields are simply lists (not array or matrix).
        Raises:
            NoCameraInfoAvailable  if no info available
            InvalidCameraInfo   if the info exists but is invalid
    """

    if robot_name == dtu.DuckietownConstants.ROBOT_NAME_FOR_TESTS:
        calib_data = dtu.yaml_load(default_camera_info)
    else:
        # find the file
        fn = get_camera_info_config_file(robot_name)

        # load the YAML

        calib_data = dtu.yaml_load_file(fn, plain_yaml=True)

    # convert the YAML
    try:
        camera_info = camera_info_from_yaml(calib_data)
    except InvalidCameraInfo as e:
        msg = 'Invalid data in file %s' % fn
        dtu.raise_wrapped(InvalidCameraInfo, e, msg)

    #check_camera_info_sane_for_DB17(camera_info)

    return camera_info
Exemplo n.º 3
0
def get_homography_for_robot(robot_name):
    dtu.check_isinstance(robot_name, str)
    # Get the config file for the homography of the robot
    filename = get_homography_info_config_file(robot_name, strict=False)
    data = dtu.yaml_load_file(filename)

    # Extract the homography from the YAML file
    homography = homography_from_yaml(data)

    return homography
Exemplo n.º 4
0
def get_homography_for_robot(robot_name):
    dtu.check_isinstance(robot_name, str)
    # find the file

    fn = get_homography_info_config_file(robot_name)

    # load the YAML
    data = dtu.yaml_load_file(fn, True)  # True means "plain"

    # convert the YAML
    homography = homography_from_yaml(data)

    return homography
Exemplo n.º 5
0
def get_homography_for_robot(robot_name):
    dtu.check_isinstance(robot_name, str)
    # find the file
    if robot_name == dtu.DuckietownConstants.ROBOT_NAME_FOR_TESTS:
        data = dtu.yaml_load(homography_default)
    else:
        fn = get_homography_info_config_file(robot_name)
        # load the YAML
        data = dtu.yaml_load_file(fn)

    # convert the YAML
    homography = homography_from_yaml(data)
    #check_homography_sane_for_DB17(homography)
    return homography
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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 load_board_info(filename=None):
    '''Load calibration checkerboard info'''
    if filename is None:
        root = dtu.get_ros_package_path('duckietown')
        filename = root + '/config/baseline/ground_projection/ground_projection/default.yaml'

    if not os.path.isfile(filename):
        msg = 'No such file: %s' % filename
        raise dtu.DTException(msg)

    target_data = dtu.yaml_load_file(filename)
    target_info = {
        'width': target_data['board_w'],
        'height': target_data['board_h'],
        'square_size': target_data['square_size'],
        'x_offset': target_data['x_offset'],
        'y_offset': target_data['y_offset'],
        'offset': np.array([target_data['x_offset'],
                            -target_data['y_offset']]),
        'size': (target_data['board_w'], target_data['board_h']),
    }
    dtu.logger.info("Loaded checkerboard parameters")
    return target_info
Exemplo n.º 9
0
Arquivo: output.py Projeto: v/Software
}

body {
    font-size: 8pt;
}
 
 
td {
    overflow-wrap: break-word;
    min-width: 4em;
    max-width: 4em;
    padding-bottom: 3px; 
}
td {
    border-bottom: solid 1px black;
}


"""
    style = Tag(name='style')
    style.append(css)
    body.append(style)
    body.append(table)
    return body


if __name__ == '__main__':
    filename = sys.argv[1]
    mongo_data = yaml_load_file(filename)
    html = create_summary(mongo_data)
    write_data_to_file(html, 'output.html')