Exemplo n.º 1
0
def difference_loop(context, start_frame):
    # load variables from context
    workspace = context.workspace
    differences_dir = context.differences_dir
    inversion_data_dir = context.inversion_data_dir
    pframe_data_dir = context.pframe_data_dir
    input_frames_dir = context.input_frames_dir
    frame_count = context.frame_count
    block_size = context.block_size
    extension_type = context.extension_type
    bleed = context.bleed
    debug = context.debug

    logger = logging.getLogger(__name__)
    logger.info((workspace, start_frame, frame_count, block_size))

    # for every frame in the video, create a difference_frame given the text files.
    for x in range(start_frame, frame_count):
        f1 = Frame()
        f1.load_from_string_wait(input_frames_dir + "frame" + str(x + 1) + extension_type)
        logger.info("waiting on text")
        logger.info(f1)

        difference_data = get_list_from_file(inversion_data_dir + "inversion_" + str(x) + ".txt")
        prediction_data = get_list_from_file(pframe_data_dir + "pframe_" + str(x) + ".txt")

        make_difference_image(context, f1, difference_data, prediction_data,
                              differences_dir + "output_" + get_lexicon_value(6, x) + ".png")

        output_file = workspace + "debug/debug" + str(x + 1) + extension_type

        if debug == 1:
            debug_image(block_size, f1, prediction_data, difference_data, output_file)
Exemplo n.º 2
0
def merge_loop(context: Context, start_frame: int):
    # load variables from context
    workspace = context.workspace
    upscaled_dir = context.upscaled_dir
    merged_dir = context.merged_dir
    inversion_data_dir = context.inversion_data_dir
    pframe_data_dir = context.pframe_data_dir
    correction_data_dir = context.correction_data_dir
    fade_data_dir = context.fade_data_dir
    frame_count = context.frame_count
    extension_type = context.extension_type
    logger = logging.getLogger(__name__)

    for x in range(start_frame, frame_count):
        logger.info("Upscaling frame " + str(x))

        # load images required to merge this frame
        f1 = Frame()
        f1.load_from_string_wait(upscaled_dir + "output_" +
                                 get_lexicon_value(6, x) + ".png")

        base = Frame()
        base.load_from_string_wait(merged_dir + "merged_" + str(x) +
                                   extension_type)

        # load vectors needed to piece image back together
        prediction_data_list = get_list_from_file(pframe_data_dir + "pframe_" +
                                                  str(x) + ".txt")
        difference_data_list = get_list_from_file(inversion_data_dir +
                                                  "inversion_" + str(x) +
                                                  ".txt")
        correction_data_list = get_list_from_file(correction_data_dir +
                                                  "correction_" + str(x) +
                                                  ".txt")
        fade_data_list = get_list_from_file(fade_data_dir + "fade_" + str(x) +
                                            ".txt")

        output_file = workspace + "merged/merged_" + str(x +
                                                         1) + extension_type

        make_merge_image(context, f1, base, prediction_data_list,
                         difference_data_list, correction_data_list,
                         fade_data_list, output_file)
Exemplo n.º 3
0
def difference_loop(workspace, difference_dir, inversion_data_dir, pframe_data_dir,
                    input_frames_dir, start_frame, count, block_size, file_type):
    logger = logging.getLogger(__name__)
    bleed = 1
    logger.info((workspace, start_frame, count, block_size))

    for x in range(start_frame, count):
        f1 = Frame()
        f1.load_from_string_wait(input_frames_dir + "frame" + str(x + 1) + file_type)
        logger.info("waiting on text")
        logger.info(f1)

        difference_data = wait_on_text(inversion_data_dir + "inversion_" + str(x) + ".txt")
        prediction_data = wait_on_text(pframe_data_dir + "pframe_" + str(x) + ".txt")

        make_difference_image(f1, block_size, bleed, difference_data, prediction_data,
                              difference_dir + "output_" + get_lexicon_value(6, x) + ".png")

        debug(workspace, block_size, bleed, f1, prediction_data, difference_data,
              workspace + "debug/debug" + str(x + 1) + file_type)
Exemplo n.º 4
0
def merge_loop(workspace, upscaled_dir, merged_dir, inversion_data_dir, pframe_data_dir,
               correction_data_dir, start_frame, count, block_size, scale_factor, file_type):
    logger = logging.getLogger(__name__)
    bleed = 1

    for x in range(start_frame, count):
        logger.info("Upscaling frame " + str(x))

        # load images required to merge this frame
        f1 = Frame()
        f1.load_from_string_wait(upscaled_dir + "output_" + get_lexicon_value(6, x) + ".png")

        base = Frame()
        base.load_from_string_wait(merged_dir + "merged_" + str(x) + file_type)

        # load vectors needed to piece image back together
        difference_data = wait_on_text(inversion_data_dir + "inversion_" + str(x) + ".txt")
        prediction_data = wait_on_text(pframe_data_dir + "pframe_" + str(x) + ".txt")

        correction_data = wait_on_text(correction_data_dir + "correction_" + str(x) + ".txt")

        make_merge_image(workspace, block_size, scale_factor, bleed, f1, base, prediction_data,
                         difference_data, correction_data, workspace + "merged/merged_" + str(x + 1) + file_type)