import os
from logica.utilidades.Output import Output
from logica.controladores.TextureController import TextureController
import logica.segmentation_logic as logica
import logica.utilidades.utils as ut
from datos.Config import ConfigManager

config = ConfigManager()
output = Output("segmentation")
tc = TextureController("imagenes_group")

FPS = 0

def set_fps(value):
    global FPS
    FPS = value

def get_fps():
    return FPS

def set_output(text):
    output.set_output(text)

def init_process(command):
    output.init_process(command)

def segmentar_video():
    if not config.is_video_folder_set() or not os.path.exists(config.DIR_VIDEO):
        set_output("A video has not been selected or does not exist.")
        return 

    if not config.is_images_folder_set() or not os.path.exists(config.IMAGES_FOLDER):
        set_output("An output folder has not been selected or does not exist.")
        return

    logica.segmentar_video_callback()

def init_texture_view(folder):
    result = tc.main_view(folder)
    if result:
        output.set_output(result)

def init_output_view():
    output.main_view()

def get_group_tag():
    return tc.get_group_tag()

def cargar_imagenes(folder):
    return tc.cargar_imagenes(folder)

def seleccionar_folder():
    return ut.seleccionar_folder_callback(output)

def delete_images(folder):
    return ut.deleteImages(folder)

def seleccionar_video():
    return ut.seleccionar_video_callback(output)