修复福袋详情OCR v2与调试日志
This commit is contained in:
1 parent
2c6f024a24
commit
1d37d57c90
119 files changed
+5582
-767
No files matched your search
@@ -10,6 +10,9 @@ from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import pytest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class TestPixelPopups:
|
||||
@@ -37,6 +40,68 @@ class TestPixelPopups:
|
||||
|
||||
assert callable(detect_lucky_draw_result_popup)
|
||||
|
||||
def test_detect_lucky_draw_result_white_confirm_button(self):
|
||||
from douyin.detection.pixel.popups import detect_lucky_draw_result_popup
|
||||
from douyin.fudai.core.coords import LOTTERY_RESULT_CONFIRM_BUTTON_PIXEL_V2
|
||||
|
||||
img = Image.new("RGB", (1080, 2400), (20, 20, 20))
|
||||
x1, y1, x2, y2 = LOTTERY_RESULT_CONFIRM_BUTTON_PIXEL_V2
|
||||
for y in range(y1, y2):
|
||||
for x in range(x1, x2):
|
||||
img.putpixel((x, y), (245, 245, 245))
|
||||
|
||||
detected, info = detect_lucky_draw_result_popup(
|
||||
img,
|
||||
return_info=True,
|
||||
analyser=SimpleNamespace(fudai_detail_ui_mode="v2_0"),
|
||||
)
|
||||
|
||||
assert detected is True
|
||||
assert info["white_ratio"] >= 0.8
|
||||
assert info["ui_version"] == "v2_0"
|
||||
assert info["pixel_style"] == "white"
|
||||
|
||||
def test_detect_lucky_draw_result_red_confirm_button_legacy(self):
|
||||
from douyin.detection.pixel.popups import detect_lucky_draw_result_popup
|
||||
from douyin.fudai.core.coords import LOTTERY_RESULT_CONFIRM_BUTTON_PIXEL_V1
|
||||
|
||||
img = Image.new("RGB", (1080, 2400), (20, 20, 20))
|
||||
x1, y1, x2, y2 = LOTTERY_RESULT_CONFIRM_BUTTON_PIXEL_V1
|
||||
for y in range(y1, y2):
|
||||
for x in range(x1, x2):
|
||||
img.putpixel((x, y), (255, 60, 100))
|
||||
|
||||
detected, info = detect_lucky_draw_result_popup(
|
||||
img,
|
||||
return_info=True,
|
||||
analyser=SimpleNamespace(fudai_detail_ui_mode="legacy"),
|
||||
)
|
||||
|
||||
assert detected is True
|
||||
assert info["red_ratio"] >= 0.8
|
||||
assert info["ui_version"] == "legacy"
|
||||
assert info["pixel_style"] == "red"
|
||||
|
||||
def test_detect_lucky_draw_result_legacy_does_not_accept_v2_white_button(self):
|
||||
from douyin.detection.pixel.popups import detect_lucky_draw_result_popup
|
||||
from douyin.fudai.core.coords import LOTTERY_RESULT_CONFIRM_BUTTON_PIXEL_V1
|
||||
|
||||
img = Image.new("RGB", (1080, 2400), (20, 20, 20))
|
||||
x1, y1, x2, y2 = LOTTERY_RESULT_CONFIRM_BUTTON_PIXEL_V1
|
||||
for y in range(y1, y2):
|
||||
for x in range(x1, x2):
|
||||
img.putpixel((x, y), (245, 245, 245))
|
||||
|
||||
detected, info = detect_lucky_draw_result_popup(
|
||||
img,
|
||||
return_info=True,
|
||||
analyser=SimpleNamespace(fudai_detail_ui_mode="legacy"),
|
||||
)
|
||||
|
||||
assert detected is False
|
||||
assert info["white_ratio"] >= 0.8
|
||||
assert info["pixel_style"] == "red"
|
||||
|
||||
|
||||
class TestPixelButtons:
|
||||
"""pixel/buttons 模块测试。"""
|
||||
@@ -84,6 +149,15 @@ class TestPixelStage:
|
||||
|
||||
assert callable(read_pixel_stage_state_from_screenshot)
|
||||
|
||||
def test_stage_module_imports_popup_helpers(self):
|
||||
import douyin.detection.pixel.stage as stage_mod
|
||||
|
||||
assert hasattr(stage_mod, "detect_coupon_popup_background")
|
||||
assert hasattr(stage_mod, "detect_redpacket_popup_background")
|
||||
assert hasattr(stage_mod, "detect_lucky_draw_result_popup")
|
||||
assert hasattr(stage_mod, "detect_attend_button_red_area")
|
||||
assert hasattr(stage_mod, "detect_fansclub_join_red_area")
|
||||
|
||||
|
||||
class TestPixelCommon:
|
||||
"""pixel/_common 模块测试。"""
|
||||
|
||||
Reference in new issue
Block a user