# Path: src/helper.py
# def validate_function_key(slot_key):
# def get_output_folder():
# def get_models_folder():
# def get_dataset_folder():
# def get_home_folder():
# def pickle_object(data, name, directory=get_output_folder()):
# def generate_img_key(image):
# def get_tensor(image):
# def get_output_vector(presses):
# def get_key_state_from_vector(vector):


import logging
import traceback
import cv2
import numpy as np
import os
from skimage.measure import block_reduce
from src import helper
""" This module implements the image downsampling component of the basic Mario Kart AI agent. """


logger = logging.getLogger(__name__)


class Downsampler:
    def __init__(self, game_name, blur_size=25, intermediate_dim=300, final_dim=10):
        self.game_name = game_name
        self.blur_size = blur_size
        if intermediate_dim % final_dim != 0:
            raise ValueError("final dimensions must divide into intermediate dimensions completely.")
        self.pooling_dim = int(intermediate_dim / final_dim)
        self.inter_dim = (intermediate_dim, intermediate_dim)
        self.screenshot_dir = os.path.join(helper.get_home_folder(), '.dolphin-emu', 'ScreenShots')

# Path: src/helper.py
# def validate_function_key(slot_key):
# def get_output_folder():
# def get_models_folder():
# def get_dataset_folder():
# def get_home_folder():
# def pickle_object(data, name, directory=get_output_folder()):
# def generate_img_key(image):
# def get_tensor(image):
# def get_output_vector(presses):
# def get_key_state_from_vector(vector):


# Path: src/mk_downsampler.py
import logging
import traceback
import cv2
import numpy as np
import os
from skimage.measure import block_reduce
from src import helper

""" This module implements the image downsampling component of the basic Mario Kart AI agent. """


logger = logging.getLogger(__name__)


class Downsampler:
    def __init__(self, game_name, blur_size=25, intermediate_dim=300, final_dim=10):
        self.game_name = game_name
        self.blur_size = blur_size
        if intermediate_dim % final_dim != 0:
            raise ValueError("final dimensions must divide into intermediate dimensions completely.")
        self.pooling_dim = int(intermediate_dim / final_dim)
        self.inter_dim = (intermediate_dim, intermediate_dim)
        self.screenshot_dir = os.path.join(helper.get_home_folder(), '.dolphin-emu', 'ScreenShots')

        self.output_dir = os.path.join(helper.get_output_folder(), "images")