D144 · 修复 subtitle-safe-area-qc 两个bug
- Bug1: detect_subtitle_box() 合并轮廓时坐标系混用(和reference-subtitle-analyzer同款bug)
修复:先在bottom_region坐标系算完,最后统一加偏移
- Bug2: detect_subtitle_box() 末尾缺少 return 语句
导致函数返回None,主流程TypeError
- 验证:测试图检测 x=103, y=1760, w=366, h=35 全部正确
✅ 5/8 工具已跑通:
1. reference-subtitle-analyzer.py
2. ass-subtitle-renderer.py
3. script-to-srt-with-timing.py
4. subtitle-preview-contact-sheet.py
5. subtitle-safe-area-qc.py
剩余:
6. subtitle-font-manager.py
7. subtitle-style-ab-test.py
8. 本地ffmpeg缺libass(烧字幕需服务器)
冰朔 TCS-0002∞ 见证
⊢ 铸渊 ICE-GL-ZY001 · D144 · 2026-06-24
This commit is contained in:
parent
9474086356
commit
9450fd09d1
@ -171,7 +171,7 @@ def detect_subtitle_box(image: np.ndarray) -> list:
|
||||
if not contours:
|
||||
return [0, int(height * 0.85), width, int(height * 0.12)] # 默认底部区域
|
||||
|
||||
# 合并所有轮廓的边界框
|
||||
# 收集所有轮廓的边界框
|
||||
all_x = []
|
||||
all_y = []
|
||||
all_w = []
|
||||
@ -184,15 +184,23 @@ def detect_subtitle_box(image: np.ndarray) -> list:
|
||||
all_w.append(w)
|
||||
all_h.append(h)
|
||||
|
||||
# 计算合并后的边界框
|
||||
x = min(all_x)
|
||||
y = min(all_y) + int(height * 0.85) # 加上裁剪偏移
|
||||
w = max(all_x) + max(all_w) - x
|
||||
h = max(all_y) + max(all_h) - y
|
||||
# 合并所有轮廓的边界框
|
||||
# 先在 bottom_region 坐标系里算完,最后再加偏移
|
||||
x_bottom = min(all_x)
|
||||
y_bottom = min(all_y)
|
||||
max_x_bottom = max([all_x[i] + all_w[i] for i in range(len(all_x))])
|
||||
max_y_bottom = max([all_y[i] + all_h[i] for i in range(len(all_y))])
|
||||
w = max_x_bottom - x_bottom
|
||||
h = max_y_bottom - y_bottom
|
||||
|
||||
# 最后统一加偏移
|
||||
x = x_bottom
|
||||
y = y_bottom + int(height * 0.85)
|
||||
# w, h 不需要加偏移(它们是在bottom_region里的尺寸)
|
||||
|
||||
return [x, y, w, h]
|
||||
|
||||
|
||||
|
||||
|
||||
def calculate_iou(box1: list, box2: list) -> float:
|
||||
"""
|
||||
计算两个边界框的 IOU(交并比)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user