improve fudai ocr debug captures
This commit is contained in:
1 parent
62c84939ee
commit
207cf0eadb
10 files changed
+382
-117
No files matched your search
@@ -169,6 +169,56 @@ def test_fudai_detail_debug_overview_supports_two_task_positions(tmp_path, monke
|
||||
assert image.getpixel((363, 1413)) == (0, 0, 0)
|
||||
|
||||
|
||||
def test_fudai_detail_debug_overview_marks_task_count_digit_box(tmp_path, monkeypatch):
|
||||
from douyin.core import path_config
|
||||
from douyin.detection.detection_pkg.detail import get_detail_task_count_digit_box
|
||||
from douyin.fudai.core import coords as coords_mod
|
||||
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,
|
||||
)
|
||||
digit_box = get_detail_task_count_digit_box(coords_mod.DETAIL_UI_V2_0["task_count"])
|
||||
|
||||
result = fudai_debug_utils.save_fudai_detail_debug_overview(
|
||||
analyser,
|
||||
[
|
||||
{
|
||||
"key": "task_count",
|
||||
"name": "任务数",
|
||||
"coords": digit_box,
|
||||
"enabled": True,
|
||||
},
|
||||
],
|
||||
ui_version="v2_0",
|
||||
ocr_enabled={"task_count"},
|
||||
task_count=2,
|
||||
task_count_source="v2_digit_template",
|
||||
)
|
||||
|
||||
assert result
|
||||
image, _kwargs = saved[0]
|
||||
assert image.getpixel((digit_box[0], digit_box[1])) != (255, 255, 255)
|
||||
assert image.getpixel((digit_box[0] + 6, digit_box[1])) != (255, 255, 255)
|
||||
assert _kwargs["extra_info"]["task_count_source"] == "v2_digit_template"
|
||||
|
||||
|
||||
def test_fudai_detail_debug_overview_keeps_existing_detail_images(tmp_path, monkeypatch):
|
||||
from douyin.core import path_config
|
||||
from douyin.fudai.core import fudai_debug_utils
|
||||
@@ -219,6 +269,31 @@ def test_fudai_detail_debug_overview_keeps_existing_detail_images(tmp_path, monk
|
||||
assert unrelated.exists()
|
||||
|
||||
|
||||
def test_cleanup_fudai_detail_debug_captures_removes_info_line_debug_image(tmp_path, monkeypatch):
|
||||
from douyin.fudai.core import fudai_debug_utils
|
||||
|
||||
debug_dir = tmp_path / "debug"
|
||||
debug_dir.mkdir()
|
||||
info_line = debug_dir / "20260603_ocr_福袋人数倒计时信息_postocr.png"
|
||||
overview = debug_dir / "20260603_ocr_福袋详情综合标注_detail_regions.png"
|
||||
keep = debug_dir / "20260603_px_pxstage_ov_ok_1.png"
|
||||
info_line.write_bytes(b"old")
|
||||
overview.write_bytes(b"old")
|
||||
keep.write_bytes(b"keep")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"douyin.handlers.douyin_screenshot_manager.get_debug_captures_dir",
|
||||
lambda: str(debug_dir),
|
||||
)
|
||||
|
||||
removed = fudai_debug_utils.cleanup_fudai_detail_debug_captures()
|
||||
|
||||
assert removed >= 2
|
||||
assert not info_line.exists()
|
||||
assert not overview.exists()
|
||||
assert keep.exists()
|
||||
|
||||
|
||||
def test_fudai_detail_debug_overview_uses_configured_profile_coords(tmp_path, monkeypatch):
|
||||
from douyin.core import path_config
|
||||
from douyin.fudai.core import coords as coords_mod
|
||||
|
||||
Reference in new issue
Block a user