优化详情调试标注与截图复用

This commit is contained in:
Your Name committed 2026-06-03 11:36:47 +08:00
1 parent 42aa0f214d
commit 3bcb5cb259
6 files changed
+169 -42

No files matched your search

+56
View File
@@ -61,6 +61,62 @@ def test_fudai_detail_debug_overview_saves_one_annotated_image(tmp_path, monkeyp
assert kwargs["extra_info"]["ui_version"] == "v2_0"
def test_fudai_detail_debug_labels_are_inside_region_edges(tmp_path, monkeypatch):
from douyin.core import path_config
from douyin.fudai.core import fudai_debug_utils
screenshot = tmp_path / "screenshot.png"
Image.new("RGB", (1080, 2400), "white").save(screenshot)
saved = []
def fake_save_debug_image(image, **kwargs):
saved.append((image.copy(), kwargs))
return str(tmp_path / "overview.png")
monkeypatch.setattr(path_config, "get_screenshot_path", lambda: str(screenshot))
monkeypatch.setattr(
"douyin.handlers.douyin_screenshot_manager.save_debug_image",
fake_save_debug_image,
)
analyser = SimpleNamespace(
resolution_ratio_x=1080,
resolution_ratio_y=2400,
_log_kv=lambda *args, **kwargs: None,
)
result = fudai_debug_utils.save_fudai_detail_debug_overview(
analyser,
[
{
"key": "countdown",
"name": "倒计时",
"coords": (760, 1355, 1035, 1455),
"enabled": True,
},
{
"key": "content",
"name": "内容",
"coords": (360, 1472, 1035, 1545),
"enabled": True,
},
],
ui_version="v2_0",
ocr_enabled={"countdown", "content"},
task_count=1,
task_count_source="v2_pixels",
)
assert result
assert saved
image, _kwargs = saved[0]
# Labels are now drawn adjacent to their own boxes, not floating above
# another OCR field.
assert image.getpixel((763, 1358)) == (0, 0, 0)
assert image.getpixel((363, 1475)) == (0, 0, 0)
assert image.getpixel((363, 1444)) != (0, 0, 0)
def test_fudai_detail_debug_overview_cleans_old_detail_images(tmp_path, monkeypatch):
from douyin.core import path_config
from douyin.fudai.core import fudai_debug_utils