예제 #1
0
def load_config(yaml_file):
    config = OmegaConf.load(yaml_file)
    aruco_params = config.get('aruco_params', {})

    boards = {k:OmegaConf.merge(config.common, board) for k, board in config.boards.items()} if 'common' in config\
      else config.boards

    def instantiate_board(config):
        if config._type_ == "charuco":
            schema = OmegaConf.structured(CharucoConfig)
            return CharucoBoard(aruco_params=aruco_params,
                                **merge_schema(config, schema))
        elif config._type_ == "aprilgrid":
            schema = OmegaConf.structured(AprilConfig)
            return AprilGrid(**merge_schema(config, schema))
        else:
            assert False, f"unknown board type: {config._type_}, options are (charuco | aprilgrid | checkerboard)"

    return {k: instantiate_board(board) for k, board in boards.items()}
예제 #2
0
def merge_schema(config, schema):
    merged = OmegaConf.merge(schema, config)
    return struct(**merged)._without('_type_')