mirror of
https://github.com/k4yt3x/video2x.git
synced 2024-12-29 16:09:10 +00:00
fixed upscaler diff threshold bug
This commit is contained in:
parent
7eabac2175
commit
ac80de9399
@ -104,9 +104,6 @@ class VideoDecoder(threading.Thread):
|
|||||||
"RGB", (self.input_width, self.input_height), buffer
|
"RGB", (self.input_width, self.input_height), buffer
|
||||||
)
|
)
|
||||||
|
|
||||||
# if this is the first frame
|
|
||||||
# there wouldn't be a "previous image"
|
|
||||||
if previous_image is not None:
|
|
||||||
self.processing_queue.put(
|
self.processing_queue.put(
|
||||||
(
|
(
|
||||||
frame_index,
|
frame_index,
|
||||||
|
@ -56,6 +56,11 @@ class Interpolator(multiprocessing.Process):
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# if image0 is None, image1 is the first frame
|
||||||
|
# skip this round
|
||||||
|
if image0 is None:
|
||||||
|
continue
|
||||||
|
|
||||||
difference = ImageChops.difference(image0, image1)
|
difference = ImageChops.difference(image0, image1)
|
||||||
difference_stat = ImageStat.Stat(difference)
|
difference_stat = ImageStat.Stat(difference)
|
||||||
difference_ratio = (
|
difference_ratio = (
|
||||||
|
@ -74,10 +74,14 @@ class Upscaler(multiprocessing.Process):
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
difference_ratio = -1
|
||||||
|
if image0 is not None:
|
||||||
difference = ImageChops.difference(image0, image1)
|
difference = ImageChops.difference(image0, image1)
|
||||||
difference_stat = ImageStat.Stat(difference)
|
difference_stat = ImageStat.Stat(difference)
|
||||||
difference_ratio = (
|
difference_ratio = (
|
||||||
sum(difference_stat.mean) / (len(difference_stat.mean) * 255) * 100
|
sum(difference_stat.mean)
|
||||||
|
/ (len(difference_stat.mean) * 255)
|
||||||
|
* 100
|
||||||
)
|
)
|
||||||
|
|
||||||
# if the difference is lower than threshold
|
# if the difference is lower than threshold
|
||||||
@ -150,6 +154,7 @@ class Upscaler(multiprocessing.Process):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
# make sure the previous frame has been processed
|
# make sure the previous frame has been processed
|
||||||
|
if frame_index > 0:
|
||||||
while self.processed_frames[frame_index - 1] is None:
|
while self.processed_frames[frame_index - 1] is None:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
@ -378,8 +378,8 @@ def parse_arguments() -> argparse.Namespace:
|
|||||||
"-t",
|
"-t",
|
||||||
"--threshold",
|
"--threshold",
|
||||||
type=float,
|
type=float,
|
||||||
help="if the % difference between two adjacent frames exceeds this value, two images are deemed the same",
|
help="if the % difference between two adjacent frames exceeds this value, two images are deemed the same; 0 is off",
|
||||||
default=0.1,
|
default=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
# interpolator arguments
|
# interpolator arguments
|
||||||
@ -400,7 +400,7 @@ def parse_arguments() -> argparse.Namespace:
|
|||||||
"-t",
|
"-t",
|
||||||
"--threshold",
|
"--threshold",
|
||||||
type=float,
|
type=float,
|
||||||
help="if the % difference between two adjacent frames exceeds this value, no interpolation will be performed",
|
help="if the % difference between two adjacent frames exceeds this value, no interpolation will be performed; 0 is off",
|
||||||
default=10,
|
default=10,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user