From 26f560e4c5771fa6a4071f2dda2e359c774cdf7c Mon Sep 17 00:00:00 2001 From: AbyssYuan0 Date: Tue, 16 Jan 2024 15:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=E5=88=86=E5=89=B2=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 11 ++--------- videoCut.py | 9 +++++++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/__init__.py b/__init__.py index 4b8091c..c29fe56 100644 --- a/__init__.py +++ b/__init__.py @@ -479,13 +479,6 @@ class VideoCutFromDir: return { "required": { "frame_dir": ("STRING", {"default": None}), - "threshold": ("FLOAT", { - "default": 0.60, - "min": 0.1, - "max": 1.0, - "step": 0.01, - "display": "number" - }), "min_frame": ("INT", { "default": 16, "min": 1, @@ -508,8 +501,8 @@ class VideoCutFromDir: CATEGORY = "badger" - def video_cut_from_dir(self, frame_dir, threshold, min_frame, max_frame): - cutList = getCutList(frame_dir, threshold, min_frame, max_frame) + def video_cut_from_dir(self, frame_dir, min_frame, max_frame): + cutList = getCutList(frame_dir, min_frame, max_frame) dirPathString = cutToDir(frame_dir, cutList) return (dirPathString,) diff --git a/videoCut.py b/videoCut.py index ed1bca1..8319421 100644 --- a/videoCut.py +++ b/videoCut.py @@ -39,7 +39,7 @@ def calculate_image_similarity(img_path1, img_path2): return combined_score -def getCutList(imagePath, threshold, min_frame, max_frame): +def getCutList(imagePath, min_frame, max_frame): pngList = os.listdir(imagePath) cutList = [] indexList = [] @@ -51,9 +51,14 @@ def getCutList(imagePath, threshold, min_frame, max_frame): imgPath0 = os.path.join(imagePath, pngList[i]) imgPath1 = os.path.join(imagePath, pngList[i + 1]) similarity = calculate_image_similarity(imgPath0, imgPath1) - print("切割画面(" + str(i + 1) + "/" + str(len(pngList) - 1)) + print("切割画面(" + str(i + 1) + "/" + str(len(pngList) - 1) +") 相似度:"+ str(similarity)) indexList.append(i) resList.append(similarity) + i += 1 + + i = min_frame - 1 + threshold = sum(resList)/len(resList) + while i < len(pngList) - 1: if num >= max_frame: num = 0 cutList.append(pngList[i])