mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-30 23:58:11 +00:00
updated value unpacking
This commit is contained in:
parent
9a27960bf7
commit
020fb2dc80
@ -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,31 +162,41 @@ class UpscalerProcessor(Processor, Upscaler):
|
|||||||
task = self.tasks_queue.get()
|
task = self.tasks_queue.get()
|
||||||
while task is not None:
|
while task is not None:
|
||||||
|
|
||||||
# unpack the task's values
|
try:
|
||||||
(
|
|
||||||
frame_index,
|
|
||||||
previous_frame,
|
|
||||||
current_frame,
|
|
||||||
processing_settings,
|
|
||||||
) = task
|
|
||||||
|
|
||||||
# calculate the %diff between the current frame and the previous frame
|
if self.pause_flag.value is True:
|
||||||
difference_ratio = 0
|
time.sleep(0.1)
|
||||||
if previous_frame is not None:
|
continue
|
||||||
difference_ratio = self.get_image_diff(previous_frame, current_frame)
|
|
||||||
|
|
||||||
# if the difference is lower than threshold, skip this frame
|
# unpack the task's values
|
||||||
if difference_ratio < processing_settings["difference_threshold"]:
|
(
|
||||||
|
frame_index,
|
||||||
|
previous_frame,
|
||||||
|
current_frame,
|
||||||
|
(output_width, output_height, algorithm, noise, threshold),
|
||||||
|
) = task
|
||||||
|
|
||||||
# make the current image the same as the previous result
|
# calculate the %diff between the current frame and the previous frame
|
||||||
self.processed_frames[frame_index] = True
|
difference_ratio = 0
|
||||||
|
if previous_frame is not None:
|
||||||
|
difference_ratio = self.get_image_diff(
|
||||||
|
previous_frame, current_frame
|
||||||
|
)
|
||||||
|
|
||||||
# if the difference is greater than threshold
|
# if the difference is lower than threshold, skip this frame
|
||||||
# process this frame
|
if difference_ratio < threshold:
|
||||||
else:
|
|
||||||
self.processed_frames[frame_index] = self.upscale_image(
|
|
||||||
**processing_settings
|
|
||||||
)
|
|
||||||
|
|
||||||
self.tasks_queue.task_done()
|
# make the current image the same as the previous result
|
||||||
task = self.tasks_queue.get()
|
self.processed_frames[frame_index] = True
|
||||||
|
|
||||||
|
# if the difference is greater than threshold
|
||||||
|
# process this frame
|
||||||
|
else:
|
||||||
|
self.processed_frames[frame_index] = self.upscale_image(
|
||||||
|
current_frame, output_width, output_height, algorithm, noise
|
||||||
|
)
|
||||||
|
|
||||||
|
task = self.tasks_queue.get()
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user