fix false fudai detail pixel detection

This commit is contained in:
Your Name committed 2026-06-04 11:51:12 +08:00
1 parent 1d564000ca
commit f07fbb305b
3 files changed
+144 -12

No files matched your search

+10 -7
View File
@@ -15,7 +15,7 @@ from typing import Any
from ._common import _ensure_detection_cache
def check_detail_height(analyser: Any) -> int:
def check_detail_height(analyser: Any, pic_rgb: Any = None) -> int:
"""Detect how many tasks are required in the fudai detail popup.
Returns:
@@ -33,7 +33,7 @@ def check_detail_height(analyser: Any) -> int:
if ui_mode == "legacy":
return _check_detail_task_count_legacy_pixels(analyser)
detected_v2_template = _check_detail_task_count_v2(analyser)
detected_v2_template = _check_detail_task_count_v2(analyser, pic_rgb=pic_rgb)
if detected_v2_template:
return detected_v2_template
@@ -432,7 +432,7 @@ def _check_detail_task_count_v2_pixels(analyser: Any) -> int:
return detected
def _check_detail_task_count_v2(analyser: Any) -> int:
def _check_detail_task_count_v2(analyser: Any, pic_rgb: Any = None) -> int:
"""Fast v2 detail task-count recognition by matching the task-count digit only."""
try:
import cv2 # type: ignore[import-untyped]
@@ -441,10 +441,13 @@ def _check_detail_task_count_v2(analyser: Any) -> int:
from douyin.core import path_config
from douyin.fudai.core.coords import DETAIL_UI_V2_0, DETAIL_UI_V2_0_ONE_TASK
pic_path = path_config.get_screenshot_path()
if not os.path.exists(pic_path):
return 0
pic = Image.open(pic_path).convert("RGB")
if pic_rgb is not None:
pic = pic_rgb.convert("RGB") if hasattr(pic_rgb, "convert") else Image.fromarray(pic_rgb).convert("RGB")
else:
pic_path = path_config.get_screenshot_path()
if not os.path.exists(pic_path):
return 0
pic = Image.open(pic_path).convert("RGB")
pic_rgb = np.asarray(pic)
pic_gray = cv2.cvtColor(pic_rgb, cv2.COLOR_RGB2GRAY)