Normalize visible island segments

This commit is contained in:
Melbar
2026-05-09 11:29:07 +02:00
parent bcaf0417b3
commit c1425003c1
6 changed files with 24 additions and 8 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -5
View File
File diff suppressed because one or more lines are too long
+19 -2
View File
@@ -282,8 +282,25 @@ def _normalize_cached_results(beats: list, results: list, cfg) -> list:
beat = beats_by_id.get(result.beat_id) beat = beats_by_id.get(result.beat_id)
if getattr(result, "segments", ()): if getattr(result, "segments", ()):
segment_threshold = cfg.cv.deep_scan.multi_shot_segment_threshold segment_threshold = cfg.cv.deep_scan.multi_shot_segment_threshold
current_islands = _reference_scoreable_segments(beat, cfg) if beat is not None else []
repaired_segments = [] repaired_segments = []
for segment in result.segments: source_segments = list(result.segments)
if beat is not None and len(source_segments) == 1 and len(current_islands) == 1:
island_start_s, island_end_s = current_islands[0]
island_duration_s = max(0.0, island_end_s - island_start_s)
segment = source_segments[0]
if (
abs(float(segment.trailer_offset_s) - island_start_s) > 0.04
or abs(float(segment.duration_s) - island_duration_s) > 0.08
):
from dataclasses import replace as _replace
source_segments[0] = _replace(
segment,
trailer_offset_s=island_start_s,
duration_s=island_duration_s,
out_point_s=float(segment.in_point_s) + island_duration_s,
)
for segment in source_segments:
if float(segment.match_score) < segment_threshold: if float(segment.match_score) < segment_threshold:
scene = _scene_by_id_light(scenes, segment.scene_id) scene = _scene_by_id_light(scenes, segment.scene_id)
if beat is not None and scene is not None: if beat is not None and scene is not None:
@@ -596,7 +613,7 @@ def _reference_scoreable_segments(beat, cfg) -> list[tuple[float, float]]:
t = 0.0 t = 0.0
while t <= beat.duration_s: while t <= beat.duration_s:
frame = grab_frame_at_path(beat.trailer_path, beat.start_s + t) frame = grab_frame_at_path(beat.trailer_path, beat.start_s + t)
scoreable = frame is not None and _is_scoreable_reference_frame(frame, cfg) scoreable = frame is not None and is_visible(frame)
if scoreable: if scoreable:
if start is None: if start is None:
start = t start = t
Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB