feat: 更新高价值房间数据,调整房间信息和时间戳;优化红包弹窗检测函数,增加返回详细信息参数

This commit is contained in:
Your Name committed 2026-01-09 16:35:23 +08:00
1 parent 0830c08fca
commit 2f01200887
6 files changed
+148 -64

No files matched your search

+2 -2
View File
@@ -28,7 +28,7 @@
"yanghao_fallback_enter_live_x": 540,
"yanghao_fallback_enter_live_y": 1200,
"fudai_find_max_attempts": 99999,
"fudai_icon_max_wait_seconds": 6.0,
"fudai_icon_max_wait_seconds": 5.0,
"fudai_icon_retry_delay_seconds": 0.1,
"fudai_exit_after_misses": 10,
"enable_back_on_misses": true,
@@ -200,7 +200,7 @@
"log_on_complete": false
},
"fudai_detail_template_threshold": 0.52,
"switch_room_wait_after_stage_diag_seconds": 5.5,
"switch_room_wait_after_stage_diag_seconds": 6.5,
"coupon_template_match_threshold": 0.35,
"attend_button_red_ratio_threshold": 0.25,
"fansclub_join_red_ratio_threshold": 0.25,
+45 -4
View File
@@ -172,7 +172,9 @@ def detect_coupon_popup_background(
return False
def detect_redpacket_popup_background(pic_rgb: Image.Image) -> bool:
def detect_redpacket_popup_background(
pic_rgb: Image.Image, return_info: bool = False
) -> bool | tuple[bool, dict]:
"""中央购物红包弹窗检测:检测中央大红包区域的红色占比。
购物红包特征:
@@ -183,6 +185,14 @@ def detect_redpacket_popup_background(pic_rgb: Image.Image) -> bool:
检测区域(基准1080x2400):大约中央区域
- 左上:(300, 400)
- 右下:(780, 1200)
参数:
pic_rgb: RGB格式的整屏截图
return_info: 是否返回详细信息(包含红色比例)
返回:
bool: 是否检测到购物红包背景(return_info=False时)
tuple[bool, dict]: (检测结果, 详细信息)(return_info=True时)
"""
try:
import numpy as np # type: ignore[import-untyped]
@@ -205,6 +215,12 @@ def detect_redpacket_popup_background(pic_rgb: Image.Image) -> bool:
y2 = max(0, min(y2, height))
if x1 >= x2 or y1 >= y2:
if return_info:
return False, {
"method": "pixel_detection",
"red_ratio": 0.0,
"reason": "invalid_region",
}
return False
# 裁剪感兴趣区域
@@ -212,6 +228,12 @@ def detect_redpacket_popup_background(pic_rgb: Image.Image) -> bool:
arr = np.array(roi)
if arr.size == 0:
if return_info:
return False, {
"method": "pixel_detection",
"red_ratio": 0.0,
"reason": "empty_roi",
}
return False
# 提取RGB通道
@@ -229,9 +251,25 @@ def detect_redpacket_popup_background(pic_rgb: Image.Image) -> bool:
red_ratio = red_pixels / total_pixels if total_pixels > 0 else 0
# 阈值:至少15%的像素满足红色特征
return red_ratio > 0.15
result = red_ratio > 0.15
except Exception:
if return_info:
reason_value: Optional[str] = None if result else "red_ratio_below_threshold"
return result, {
"method": "pixel_detection",
"red_ratio": float(red_ratio),
"effective_threshold": 0.15,
"reason": reason_value,
}
return result
except Exception as e: # type: ignore[general-exception]
if return_info:
return False, {
"method": "pixel_detection",
"red_ratio": 0.0,
"reason": f"exception: {str(e)}",
}
return False
@@ -1041,7 +1079,9 @@ def read_pixel_stage_state_from_screenshot(
template_threshold=coupon_threshold,
analyser=analyser,
),
"has_redpacket_bg": detect_redpacket_popup_background,
"has_redpacket_bg": lambda pic: detect_redpacket_popup_background(
pic, return_info=True
),
"has_lucky_draw_result": lambda pic: detect_lucky_draw_result_popup(
pic, lucky_draw_red_ratio_threshold, return_info=True
),
@@ -1073,6 +1113,7 @@ def read_pixel_stage_state_from_screenshot(
with ThreadPoolExecutor(max_workers=8) as executor:
# 提交所有任务,并记录开始时间
import time
future_to_key = {}
for key, detect_func in detection_tasks.items():
start_time = time.time()
+12 -5
View File
@@ -115,7 +115,7 @@ class FudaiDetector:
try:
self.analyser._log_kv(
"[福袋查找] 初始化",
f"调试图像管理器状态: {'可用' if douyin_screenshot_manager else '不可用'}"
f"调试图像管理器状态: {'可用' if douyin_screenshot_manager else '不可用'}",
)
except Exception:
pass
@@ -312,7 +312,9 @@ class FudaiDetector:
if debug_path:
try:
self.analyser._log_kv(
"[调试图像]", "福袋图标像素检测命中保存", path=debug_path
"[调试图像]",
"福袋图标像素检测命中保存",
path=debug_path,
)
except Exception:
pass
@@ -479,21 +481,26 @@ class FudaiDetector:
if debug_path:
try:
self.analyser._log_kv(
"[调试图像]", "福袋图标逐像素检测命中保存", path=debug_path
"[调试图像]",
"福袋图标逐像素检测命中保存",
path=debug_path,
)
except Exception:
pass
else:
try:
self.analyser._log_kv(
"[调试图像]", "福袋图标逐像素检测命中但截图管理器不可用"
"[调试图像]",
"福袋图标逐像素检测命中但截图管理器不可用",
)
except Exception:
pass
except Exception as e:
try:
self.analyser._log_kv(
"[调试图像]", "福袋图标逐像素检测命中保存失败", error=str(e)
"[调试图像]",
"福袋图标逐像素检测命中保存失败",
error=str(e),
)
except Exception:
pass
+18 -1
View File
@@ -243,7 +243,24 @@ class LoggingWrapper:
if v is None:
continue
# 只显示关键字段:耗时、价值、错误等
if k in ("elapsed_seconds", "value_yuan", "error", "room_pos", "future_ts", "elapsed_ms", "分数", "置信度", "阈值", "红色比例", "匹配分数", "模板匹配分数", "平均分", "检测结果", "检测方法", "耗时(ms)"):
if k in (
"elapsed_seconds",
"value_yuan",
"error",
"room_pos",
"future_ts",
"elapsed_ms",
"分数",
"置信度",
"阈值",
"红色比例",
"匹配分数",
"模板匹配分数",
"平均分",
"检测结果",
"检测方法",
"耗时(ms)",
):
key_cn = key_map.get(str(k), k)
if isinstance(v, float):
if "seconds" in k or "elapsed" in k:
+3 -1
View File
@@ -95,7 +95,9 @@ def format_gui_log_line(line: str) -> str:
def _is_score_field(k: str) -> bool:
kl = k.lower()
return "score" in kl or "match" in kl or "匹配" in k or "相似" in k or "耗时" in k
return (
"score" in kl or "match" in kl or "匹配" in k or "相似" in k or "耗时" in k
)
# 解析字段
words = msg_part.split()
+68 -51
View File
@@ -1,7 +1,7 @@
{
"updated_ts": 1767942535.0661564,
"updated_ts": 1767947558.7674894,
"reason": "reservation",
"total": 147,
"total": 148,
"rooms": [
{
"first_seen_ts": 1765799932.458368,
@@ -548,10 +548,10 @@
},
{
"first_seen_ts": 1765736209.4437785,
"last_seen_ts": 1767942493.60277,
"seen_count": 74,
"pos_seen": 4,
"pos_updated_ts": 1767942493.60277,
"last_seen_ts": 1767946638.6337235,
"seen_count": 78,
"pos_seen": 8,
"pos_updated_ts": 1767946638.6337235,
"room_title_raw_last": "梵象名品",
"alias_raw": [
"梵象名品...",
@@ -1582,10 +1582,10 @@
},
{
"first_seen_ts": 1767853143.7722397,
"last_seen_ts": 1767941914.0201733,
"seen_count": 16,
"pos_seen": 3,
"pos_updated_ts": 1767941914.0201733,
"last_seen_ts": 1767944048.3629606,
"seen_count": 18,
"pos_seen": 7,
"pos_updated_ts": 1767944048.3629606,
"room_title_raw_last": "隋心",
"alias_raw": [
"隋心"
@@ -1598,10 +1598,10 @@
},
{
"first_seen_ts": 1767853185.2990494,
"last_seen_ts": 1767942093.21747,
"seen_count": 49,
"pos_seen": 2,
"pos_updated_ts": 1767942093.21747,
"last_seen_ts": 1767947558.7674894,
"seen_count": 52,
"pos_seen": 5,
"pos_updated_ts": 1767947558.7674894,
"room_title_raw_last": "作业帮数",
"alias_raw": [
"作业帮数"
@@ -1614,10 +1614,10 @@
},
{
"first_seen_ts": 1767855835.1611204,
"last_seen_ts": 1767941289.9790452,
"seen_count": 15,
"pos_seen": 4,
"pos_updated_ts": 1767941289.9790452,
"last_seen_ts": 1767947007.7622156,
"seen_count": 20,
"pos_seen": 1,
"pos_updated_ts": 1767947007.7622156,
"room_title_raw_last": "逍遥珠宝",
"alias_raw": [
"逍遥珠宝"
@@ -1647,10 +1647,10 @@
},
{
"first_seen_ts": 1767856135.4817257,
"last_seen_ts": 1767887346.7268648,
"seen_count": 31,
"last_seen_ts": 1767947109.1286912,
"seen_count": 39,
"pos_seen": 9,
"pos_updated_ts": 1767887346.7268648,
"pos_updated_ts": 1767947109.1286912,
"room_title_raw_last": "六号折扣",
"alias_raw": [
"六号折扣"
@@ -1695,10 +1695,10 @@
},
{
"first_seen_ts": 1767858236.204543,
"last_seen_ts": 1767939517.6106443,
"seen_count": 8,
"pos_seen": 4,
"pos_updated_ts": 1767939517.6106443,
"last_seen_ts": 1767946266.9178317,
"seen_count": 20,
"pos_seen": 3,
"pos_updated_ts": 1767946266.9178317,
"room_title_raw_last": "千寻Chihirc",
"alias_raw": [
"千寻Chihirc"
@@ -1840,10 +1840,10 @@
},
{
"first_seen_ts": 1767863974.4459054,
"last_seen_ts": 1767941958.2581892,
"seen_count": 30,
"pos_seen": 1,
"pos_updated_ts": 1767941958.2581892,
"last_seen_ts": 1767947508.7664201,
"seen_count": 47,
"pos_seen": 3,
"pos_updated_ts": 1767947508.7664201,
"room_title_raw_last": "交个朋友。",
"alias_raw": [
"交个朋友",
@@ -1851,7 +1851,7 @@
],
"key_kind": "norm",
"last_content": "",
"last_prize_value_yuan": 1199.0,
"last_prize_value_yuan": 699.0,
"max_prize_value_yuan": 1199.0,
"room_title": "交个朋友"
},
@@ -1954,13 +1954,14 @@
},
{
"first_seen_ts": 1767873899.5342953,
"last_seen_ts": 1767873899.5342953,
"seen_count": 1,
"pos_seen": 9,
"pos_updated_ts": 1767873899.5342953,
"room_title_raw_last": "Entertain_",
"last_seen_ts": 1767946819.3613539,
"seen_count": 2,
"pos_seen": 3,
"pos_updated_ts": 1767946819.3613539,
"room_title_raw_last": "Entertain",
"alias_raw": [
"Entertain_"
"Entertain_",
"Entertain"
],
"key_kind": "norm",
"last_content": "",
@@ -2339,10 +2340,10 @@
},
{
"first_seen_ts": 1767924514.7214658,
"last_seen_ts": 1767940263.535722,
"seen_count": 7,
"last_seen_ts": 1767947147.5061107,
"seen_count": 8,
"pos_seen": 1,
"pos_updated_ts": 1767940263.535722,
"pos_updated_ts": 1767947147.5061107,
"room_title_raw_last": "演员朱泳",
"alias_raw": [
"演员朱泳。",
@@ -2357,10 +2358,10 @@
},
{
"first_seen_ts": 1767924845.0501997,
"last_seen_ts": 1767939549.9048152,
"seen_count": 14,
"pos_seen": 5,
"pos_updated_ts": 1767939549.9048152,
"last_seen_ts": 1767944804.93843,
"seen_count": 18,
"pos_seen": 4,
"pos_updated_ts": 1767944804.93843,
"room_title_raw_last": "作业帮教",
"alias_raw": [
"作业帮教"
@@ -2470,10 +2471,10 @@
},
{
"first_seen_ts": 1767939973.9032884,
"last_seen_ts": 1767942429.8020463,
"seen_count": 2,
"pos_seen": 1,
"pos_updated_ts": 1767942429.8020463,
"last_seen_ts": 1767944995.7188,
"seen_count": 5,
"pos_seen": 7,
"pos_updated_ts": 1767944995.7188,
"room_title_raw_last": "交个朋友00",
"alias_raw": [
"交个朋友00"
@@ -2486,10 +2487,10 @@
},
{
"first_seen_ts": 1767941633.2204504,
"last_seen_ts": 1767941633.2204504,
"seen_count": 1,
"pos_seen": 0,
"pos_updated_ts": 1767941633.2204504,
"last_seen_ts": 1767946917.9022043,
"seen_count": 2,
"pos_seen": 8,
"pos_updated_ts": 1767946917.9022043,
"room_title_raw_last": "漓员朱泳。",
"alias_raw": [
"漓员朱泳。"
@@ -2515,6 +2516,22 @@
"last_prize_value_yuan": 1199.0,
"max_prize_value_yuan": 1199.0,
"room_title": "孙钛呗"
},
{
"first_seen_ts": 1767943339.0853522,
"last_seen_ts": 1767943339.0853522,
"seen_count": 1,
"pos_seen": 6,
"pos_updated_ts": 1767943339.0853522,
"room_title_raw_last": "孙钛\"",
"alias_raw": [
"孙钛\""
],
"key_kind": "norm",
"last_content": "",
"last_prize_value_yuan": 1199.0,
"max_prize_value_yuan": 1199.0,
"room_title": "孙钛"
}
]
}