From 8a8088be1fc8f0f8ef2749f27cb217d349607e29 Mon Sep 17 00:00:00 2001 From: YaoFANGUK Date: Fri, 29 Dec 2023 10:48:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E5=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gui.py b/gui.py index fcaad44..a0de340 100644 --- a/gui.py +++ b/gui.py @@ -15,6 +15,7 @@ import multiprocessing sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import backend.main +from backend.tools.common_tools import is_image_file class SubtitleRemoverGUI: @@ -309,7 +310,18 @@ class SubtitleRemoverGUI: """ if event == '-SLIDER-' or event == '-Y-SLIDER-' or event == '-Y-SLIDER-H-' or event == '-X-SLIDER-' or event \ == '-X-SLIDER-W-': - if self.video_cap is not None and self.video_cap.isOpened(): + # 判断是否时单张图片 + if is_image_file(self.video_path): + img = cv2.imread(self.video_path) + self.window['-Y-SLIDER-H-'].update(range=(0, self.frame_height - values['-Y-SLIDER-'])) + self.window['-X-SLIDER-W-'].update(range=(0, self.frame_width - values['-X-SLIDER-'])) + # 画字幕框 + y = int(values['-Y-SLIDER-']) + h = int(values['-Y-SLIDER-H-']) + x = int(values['-X-SLIDER-']) + w = int(values['-X-SLIDER-W-']) + self._update_preview(img, (y, h, x, w)) + elif self.video_cap is not None and self.video_cap.isOpened(): frame_no = int(values['-SLIDER-']) self.video_cap.set(cv2.CAP_PROP_POS_FRAMES, frame_no) ret, frame = self.video_cap.read()