2026-05-18-20-35-32 修复结果视频关键帧空白

This commit is contained in:
2026-05-18 20:39:52 +08:00
parent 5264c5c7fc
commit 69444ced72
6 changed files with 93 additions and 1 deletions

View File

@@ -12,7 +12,7 @@ from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse, Response
from fastapi.staticfiles import StaticFiles
from backend.segmentation import METHOD_DESCRIPTIONS, compare_frame, segment_frame
from backend.segmentation import METHOD_DESCRIPTIONS, compare_frame, overlay_mask, segment_frame
ROOT = Path(__file__).resolve().parents[1]
@@ -213,6 +213,7 @@ def _process_video(
frame_index = 0
selected_count = 0
written_count = 0
active_mask = None
writer = None
raw_video_path = job_path / f"{method}_overlay.raw.mp4"
video_path = job_path / f"{method}_overlay.mp4"
@@ -251,6 +252,7 @@ def _process_video(
)
)
video_output = next(item for item in outputs if item.method == "fusion")
active_mask = video_output.mask
video_frame = video_output.overlay
selected_count += 1
elif should_process:
@@ -267,8 +269,11 @@ def _process_video(
frame_index,
)
)
active_mask = video_output.mask
video_frame = video_output.overlay
selected_count += 1
elif active_mask is not None:
video_frame = overlay_mask(frame, active_mask)
if writer is None:
height, width = frame.shape[:2]