updated value unpacking

This commit is contained in:
k4yt3x 2022-05-01 08:42:13 +00:00
parent 9a27960bf7
commit 020fb2dc80

View File

@ -23,7 +23,7 @@ Last Modified: April 10, 2022
""" """
import math import math
import queue import time
from PIL import Image from PIL import Image
from realcugan_ncnn_vulkan_python import Realcugan from realcugan_ncnn_vulkan_python import Realcugan
@ -162,21 +162,29 @@ class UpscalerProcessor(Processor, Upscaler):
task = self.tasks_queue.get() task = self.tasks_queue.get()
while task is not None: while task is not None:
try:
if self.pause_flag.value is True:
time.sleep(0.1)
continue
# unpack the task's values # unpack the task's values
( (
frame_index, frame_index,
previous_frame, previous_frame,
current_frame, current_frame,
processing_settings, (output_width, output_height, algorithm, noise, threshold),
) = task ) = task
# calculate the %diff between the current frame and the previous frame # calculate the %diff between the current frame and the previous frame
difference_ratio = 0 difference_ratio = 0
if previous_frame is not None: if previous_frame is not None:
difference_ratio = self.get_image_diff(previous_frame, current_frame) difference_ratio = self.get_image_diff(
previous_frame, current_frame
)
# if the difference is lower than threshold, skip this frame # if the difference is lower than threshold, skip this frame
if difference_ratio < processing_settings["difference_threshold"]: if difference_ratio < threshold:
# make the current image the same as the previous result # make the current image the same as the previous result
self.processed_frames[frame_index] = True self.processed_frames[frame_index] = True
@ -185,8 +193,10 @@ class UpscalerProcessor(Processor, Upscaler):
# process this frame # process this frame
else: else:
self.processed_frames[frame_index] = self.upscale_image( self.processed_frames[frame_index] = self.upscale_image(
**processing_settings current_frame, output_width, output_height, algorithm, noise
) )
self.tasks_queue.task_done()
task = self.tasks_queue.get() task = self.tasks_queue.get()
except KeyboardInterrupt:
break