新增视频场景检测

This commit is contained in:
YaoFANGUK
2023-12-12 17:06:05 +08:00
parent 1cb7705660
commit 6d741cd9e4
27 changed files with 9139 additions and 0 deletions

View File

@@ -5,6 +5,10 @@ from pathlib import Path
import threading
import cv2
import sys
from backend.scenedetect import scene_detect
from backend.scenedetect.detectors import ContentDetector
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__))))
from backend.inpaint.lama_inpaint import LamaInpaint
@@ -116,6 +120,21 @@ class SubtitleDetect:
new_subtitle_frame_no_box_dict[key] = subtitle_frame_no_box_dict[key]
return new_subtitle_frame_no_box_dict
@staticmethod
def get_scene_div_frame_no(v_path):
"""
获取发生场景切换的帧号
"""
scene_div_frame_no_list = []
scene_list = scene_detect(v_path, ContentDetector())
for scene in scene_list:
start, end = scene
if start.frame_num == 0:
pass
else:
scene_div_frame_no_list.append(start.frame_num + 1)
return scene_div_frame_no_list
@staticmethod
def are_similar(region1, region2):
"""判断两个区域是否相似。"""