623 lines
23 KiB
Python
623 lines
23 KiB
Python
"""调试参数 Tab UI 创建逻辑(含 30 个 var + 4 个内部闭包)。
|
||
|
||
从 ``gui/gui_app.py`` 抽出。原本是 ``main()`` 内长 430 行的 widget 创建段。
|
||
依赖通过显式参数注入:
|
||
- ``parent`` - ``left_notebook`` (tab 父容器)
|
||
- ``vars_`` - 名→Var 的 ``Dict[str, tk.Variable]``,键名同原 ``main()``
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import tkinter as tk
|
||
from tkinter import ttk
|
||
from tkinter.constants import LEFT, BOTH, X
|
||
from typing import Dict
|
||
|
||
|
||
_REGION_SECTIONS = (
|
||
(
|
||
"legacy OCR",
|
||
(
|
||
("fudai_detail_regions", "legacy", "content", "内容"),
|
||
("fudai_detail_regions", "legacy", "value", "价值"),
|
||
("fudai_detail_regions", "legacy", "countdown_full", "倒计时"),
|
||
("fudai_detail_regions", "legacy", "task_list", "任务列表"),
|
||
("fudai_detail_regions", "legacy", "task_count", "任务数量"),
|
||
("fudai_detail_regions", "legacy", "participants", "人数"),
|
||
("fudai_detail_regions", "legacy", "button", "按钮"),
|
||
("fudai_detail_regions", "legacy", "live_title", "直播间标题"),
|
||
),
|
||
),
|
||
(
|
||
"v2_0 two task OCR",
|
||
(
|
||
("fudai_detail_regions", "v2_0_two_task", "content", "内容"),
|
||
("fudai_detail_regions", "v2_0_two_task", "value", "价值"),
|
||
("fudai_detail_regions", "v2_0_two_task", "countdown_full", "倒计时"),
|
||
("fudai_detail_regions", "v2_0_two_task", "task_list", "任务列表"),
|
||
("fudai_detail_regions", "v2_0_two_task", "task_count", "任务数量"),
|
||
("fudai_detail_regions", "v2_0_two_task", "participants", "人数"),
|
||
("fudai_detail_regions", "v2_0_two_task", "button", "按钮"),
|
||
("fudai_detail_regions", "v2_0_two_task", "live_title", "直播间标题"),
|
||
),
|
||
),
|
||
(
|
||
"v2_0 one task OCR",
|
||
(
|
||
("fudai_detail_regions", "v2_0_one_task", "content", "内容"),
|
||
("fudai_detail_regions", "v2_0_one_task", "value", "价值"),
|
||
("fudai_detail_regions", "v2_0_one_task", "countdown_full", "倒计时"),
|
||
("fudai_detail_regions", "v2_0_one_task", "info_line", "信息行"),
|
||
("fudai_detail_regions", "v2_0_one_task", "task_list", "任务列表"),
|
||
("fudai_detail_regions", "v2_0_one_task", "task_count", "任务数量"),
|
||
("fudai_detail_regions", "v2_0_one_task", "participants", "人数"),
|
||
("fudai_detail_regions", "v2_0_one_task", "button", "按钮"),
|
||
("fudai_detail_regions", "v2_0_one_task", "live_title", "直播间标题"),
|
||
),
|
||
),
|
||
(
|
||
"像素检测区域",
|
||
(
|
||
("pixel_regions", "lottery_result", "button", "开奖按钮"),
|
||
("pixel_regions", "lottery_result", "pixel", "开奖像素"),
|
||
("pixel_regions", "lottery_result", "click", "开奖点击"),
|
||
("pixel_regions", "attend_button", None, "参与按钮"),
|
||
("pixel_regions", "fansclub_join", None, "粉丝团"),
|
||
("pixel_regions", "coupon_popup", None, "优惠券"),
|
||
("pixel_regions", "shopping_redpacket", None, "购物红包"),
|
||
("pixel_regions", "fudai_detail_body", None, "详情主体"),
|
||
("pixel_regions", "live_room_icon_bbox", None, "直播间图标bbox"),
|
||
),
|
||
),
|
||
)
|
||
|
||
|
||
def _make_region_var_key(root: str, scope: str, name: str | None, axis: str) -> str:
|
||
if name:
|
||
return f"{root}_{scope}_{name}_{axis}_var"
|
||
return f"{root}_{scope}_{axis}_var"
|
||
|
||
|
||
def _add_region_editor(parent: ttk.Frame, *, root: str, scope: str, name: str | None, label: str, vars_: Dict[str, tk.Variable]) -> None:
|
||
row = ttk.Frame(parent)
|
||
row.pack(fill=X, padx=10, pady=(0, 4))
|
||
ttk.Label(row, text=f"{label}:", width=14).pack(side=LEFT)
|
||
for axis in ("x1", "y1", "x2", "y2"):
|
||
ttk.Label(row, text=f"{axis}").pack(side=LEFT, padx=(4, 2))
|
||
ttk.Spinbox(
|
||
row,
|
||
from_=-9999,
|
||
to=9999,
|
||
increment=1,
|
||
textvariable=vars_[_make_region_var_key(root, scope, name, axis)],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
|
||
|
||
def setup_debug_tab(parent: ttk.Notebook, *, vars_: Dict[str, tk.Variable]) -> ttk.Frame:
|
||
debug_tab = ttk.Frame(parent)
|
||
|
||
# 为调试参数标签页添加滚动条
|
||
debug_canvas = tk.Canvas(debug_tab, highlightthickness=0)
|
||
debug_scrollbar = ttk.Scrollbar(
|
||
debug_tab, orient="vertical", command=debug_canvas.yview
|
||
)
|
||
debug_scrollable_frame = ttk.Frame(debug_canvas)
|
||
|
||
debug_scrollable_frame.bind(
|
||
"<Configure>",
|
||
lambda e: debug_canvas.configure(scrollregion=debug_canvas.bbox("all")),
|
||
)
|
||
|
||
debug_canvas.create_window((0, 0), window=debug_scrollable_frame, anchor="nw")
|
||
debug_canvas.configure(yscrollcommand=debug_scrollbar.set)
|
||
|
||
# 鼠标滚轮支持
|
||
def _on_mousewheel(event):
|
||
debug_canvas.yview_scroll(int(-1 * (event.delta / 120)), "units")
|
||
|
||
def _on_shift_mousewheel(event):
|
||
debug_canvas.xview_scroll(int(-1 * (event.delta / 120)), "units")
|
||
|
||
debug_canvas.bind_all("<MouseWheel>", _on_mousewheel)
|
||
debug_canvas.bind_all("<Shift-MouseWheel>", _on_shift_mousewheel)
|
||
|
||
debug_canvas.pack(side="left", fill="both", expand=True)
|
||
debug_scrollbar.pack(side="right", fill="y")
|
||
|
||
parent.add(debug_tab, text="调试参数")
|
||
|
||
# 使用scrollable_frame作为容器
|
||
debug_container = debug_scrollable_frame
|
||
|
||
# 调试图像
|
||
debug_captures_box = ttk.LabelFrame(debug_container, text="调试图像")
|
||
debug_captures_box.pack(fill=X, padx=10, pady=(10, 10))
|
||
|
||
debug_r0 = ttk.Frame(debug_captures_box)
|
||
debug_r0.pack(fill=X, padx=10, pady=(10, 8))
|
||
ttk.Checkbutton(
|
||
debug_r0,
|
||
text="全局调试图像(OCR / 像素 / 模板等)",
|
||
variable=vars_["debug_captures_enabled_var"],
|
||
).pack(side=LEFT)
|
||
ttk.Checkbutton(
|
||
debug_r0,
|
||
text="异步保存调试图像(默认启用)",
|
||
variable=vars_["debug_captures_async_save_var"],
|
||
).pack(side=LEFT, padx=(10, 0))
|
||
ttk.Checkbutton(
|
||
debug_r0,
|
||
text="保存完成后记录日志(显示路径)",
|
||
variable=vars_["debug_captures_log_on_complete_var"],
|
||
).pack(side=LEFT, padx=(10, 0))
|
||
# 异步保存计数显示与重置
|
||
debug_counts_frame = ttk.Frame(debug_r0)
|
||
debug_counts_frame.pack(side=LEFT, padx=(10, 0))
|
||
ttk.Label(debug_counts_frame, text="异步保存:").pack(side=LEFT)
|
||
ttk.Label(
|
||
debug_counts_frame, textvariable=vars_["debug_async_success_var"], foreground="green"
|
||
).pack(side=LEFT, padx=(4, 8))
|
||
ttk.Label(debug_counts_frame, text="/").pack(side=LEFT)
|
||
ttk.Label(
|
||
debug_counts_frame, textvariable=vars_["debug_async_failure_var"], foreground="red"
|
||
).pack(side=LEFT, padx=(4, 8))
|
||
|
||
def on_reset_async_counters():
|
||
try:
|
||
from douyin.handlers import douyin_screenshot_manager
|
||
douyin_screenshot_manager.reset_async_save_counters()
|
||
vars_["debug_async_success_var"].set(0)
|
||
vars_["debug_async_failure_var"].set(0)
|
||
except Exception:
|
||
pass
|
||
|
||
ttk.Button(
|
||
debug_counts_frame, text="重置", command=on_reset_async_counters, width=6
|
||
).pack(side=LEFT, padx=(6, 0))
|
||
|
||
# 周期性更新计数器(2秒)
|
||
def _update_async_counters():
|
||
try:
|
||
from douyin.handlers import douyin_screenshot_manager
|
||
s, f = douyin_screenshot_manager.get_async_save_counters()
|
||
vars_["debug_async_success_var"].set(s)
|
||
vars_["debug_async_failure_var"].set(f)
|
||
except Exception:
|
||
pass
|
||
try:
|
||
debug_r0.after(2000, _update_async_counters)
|
||
except Exception:
|
||
pass
|
||
|
||
# 启动更新循环
|
||
try:
|
||
_update_async_counters()
|
||
except Exception:
|
||
pass
|
||
|
||
debug_cleanup_box = ttk.LabelFrame(debug_container, text="调试图像清理")
|
||
debug_cleanup_box.pack(fill=X, padx=10, pady=(0, 10))
|
||
|
||
debug_r1 = ttk.Frame(debug_cleanup_box)
|
||
debug_r1.pack(fill=X, padx=10, pady=(10, 8))
|
||
ttk.Checkbutton(
|
||
debug_r1, text="启用自动清理调试图像", variable=vars_["debug_captures_auto_cleanup_var"]
|
||
).pack(side=LEFT)
|
||
|
||
debug_r2 = ttk.Frame(debug_cleanup_box)
|
||
debug_r2.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Label(debug_r2, text="保留天数:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
debug_r2,
|
||
from_=1,
|
||
to=30,
|
||
increment=1,
|
||
textvariable=vars_["debug_captures_keep_days_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(debug_r2, text="最大文件数量:").pack(side=LEFT, padx=(20, 0))
|
||
ttk.Spinbox(
|
||
debug_r2,
|
||
from_=100,
|
||
to=10000,
|
||
increment=100,
|
||
textvariable=vars_["debug_captures_max_files_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(debug_r2, text="(超过此数量自动清理)").pack(side=LEFT, padx=(6, 0))
|
||
|
||
# 找福袋参数
|
||
fudai_find_box = ttk.LabelFrame(debug_container, text="找福袋参数")
|
||
fudai_find_box.pack(fill=X, padx=10, pady=(0, 10))
|
||
|
||
row4 = ttk.Frame(fudai_find_box)
|
||
row4.pack(fill=X, padx=10, pady=(10, 8))
|
||
ttk.Label(row4, text="找福袋最大尝试次数:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
row4,
|
||
from_=0,
|
||
to=50,
|
||
increment=1,
|
||
textvariable=vars_["fudai_find_max_attempts_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4, text="(0=使用默认值)").pack(side=LEFT, padx=(6, 0))
|
||
|
||
row4b = ttk.Frame(fudai_find_box)
|
||
row4b.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Label(row4b, text="找福袋重试间隔(秒):").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
row4b,
|
||
from_=0.1,
|
||
to=3.0,
|
||
increment=0.1,
|
||
textvariable=vars_["fudai_icon_retry_delay_seconds_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4b, text=" 最大等待时间(秒):").pack(side=LEFT, padx=(10, 0))
|
||
ttk.Spinbox(
|
||
row4b,
|
||
from_=0.0,
|
||
to=30.0,
|
||
increment=0.5,
|
||
textvariable=vars_["fudai_icon_max_wait_seconds_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4b, text="(实际识别常见 4-6 秒)").pack(side=LEFT, padx=(6, 0))
|
||
|
||
row4d = ttk.Frame(fudai_find_box)
|
||
row4d.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Label(row4d, text="点击福袋后等待时间(秒):").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
row4d,
|
||
from_=0.5,
|
||
to=10.0,
|
||
increment=0.1,
|
||
textvariable=vars_["fudai_click_wait_seconds_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4d, text="(等待福袋详情页加载,默认1.0秒)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
row4c = ttk.Frame(fudai_find_box)
|
||
row4c.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Checkbutton(
|
||
row4c,
|
||
text="禁用福袋内容OCR识别",
|
||
variable=vars_["fudai_disable_content_recognition_var"],
|
||
onvalue=True,
|
||
offvalue=False,
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4c, text="(仅影响 content OCR,不改其它识别模块)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
# 任务列表 OCR 开关
|
||
ttk.Checkbutton(
|
||
row4c,
|
||
text="禁用福袋任务列表OCR识别",
|
||
variable=vars_["fudai_disable_task_recognition_var"],
|
||
onvalue=True,
|
||
offvalue=False,
|
||
).pack(side=LEFT, padx=(12, 0))
|
||
|
||
row4ocr_mode = ttk.Frame(fudai_find_box)
|
||
row4ocr_mode.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Label(row4ocr_mode, text="福袋详情页UI版本:").pack(side=LEFT)
|
||
ttk.Combobox(
|
||
row4ocr_mode,
|
||
textvariable=vars_["fudai_detail_ui_mode_var"],
|
||
values=("auto", "legacy", "v2_0"),
|
||
width=10,
|
||
state="readonly",
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4ocr_mode, text="(auto优先2.0,失败保留旧版回退)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
row4debug = ttk.Frame(fudai_find_box)
|
||
row4debug.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Checkbutton(
|
||
row4debug,
|
||
text="保存福袋详情综合标注图(仅一张,不保存逐字段裁剪图)",
|
||
variable=vars_["fudai_detail_save_debug_images_var"],
|
||
).pack(side=LEFT)
|
||
ttk.Label(
|
||
row4debug,
|
||
text="(不受全局调试图像开关影响,用于核对2.0坐标)",
|
||
).pack(side=LEFT, padx=(6, 0))
|
||
|
||
row4ocr1 = ttk.Frame(fudai_find_box)
|
||
row4ocr1.pack(fill=X, padx=10, pady=(0, 8))
|
||
for label, var_name in (
|
||
("内容OCR", "fudai_detail_ocr_content_enabled_var"),
|
||
("价值OCR", "fudai_detail_ocr_value_enabled_var"),
|
||
("倒计时OCR", "fudai_detail_ocr_countdown_enabled_var"),
|
||
("任务OCR", "fudai_detail_ocr_task_enabled_var"),
|
||
("任务数量OCR", "fudai_detail_ocr_task_count_enabled_var"),
|
||
):
|
||
ttk.Checkbutton(row4ocr1, text=label, variable=vars_[var_name]).pack(
|
||
side=LEFT, padx=(0, 10)
|
||
)
|
||
|
||
row4ocr2 = ttk.Frame(fudai_find_box)
|
||
row4ocr2.pack(fill=X, padx=10, pady=(0, 8))
|
||
for label, var_name in (
|
||
("按钮文案OCR", "fudai_detail_ocr_button_enabled_var"),
|
||
("人数OCR(默认关)", "fudai_detail_ocr_participants_enabled_var"),
|
||
("直播间标题OCR(默认关)", "fudai_detail_ocr_live_title_enabled_var"),
|
||
):
|
||
ttk.Checkbutton(row4ocr2, text=label, variable=vars_[var_name]).pack(
|
||
side=LEFT, padx=(0, 10)
|
||
)
|
||
|
||
row4e = ttk.Frame(fudai_find_box)
|
||
row4e.pack(fill=X, padx=10, pady=(0, 8))
|
||
ttk.Label(row4e, text="切换直播间后等待时间(秒):").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
row4e,
|
||
from_=0.0,
|
||
to=30.0,
|
||
increment=0.5,
|
||
textvariable=vars_["switch_room_wait_after_stage_diag_seconds_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(row4e, text="(阶段检测后等待福袋加载,默认7.0秒)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
row4c = ttk.Frame(fudai_find_box)
|
||
row4c.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(row4c, text="直播间检测阈值(白色像素比例):").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
row4c,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["live_room_match_threshold_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(
|
||
row4c, text="(0.0~1.0,默认0.8,多边形区域白色像素比例>=此值判定为在直播间)"
|
||
).pack(side=LEFT, padx=(6, 0))
|
||
|
||
region_box = ttk.LabelFrame(debug_container, text="福袋坐标配置")
|
||
region_box.pack(fill=X, padx=10, pady=(0, 10))
|
||
for section_title, items in _REGION_SECTIONS:
|
||
section = ttk.LabelFrame(region_box, text=section_title)
|
||
section.pack(fill=X, padx=10, pady=(8, 6))
|
||
for root, scope, name, label in items:
|
||
_add_region_editor(section, root=root, scope=scope, name=name, label=label, vars_=vars_)
|
||
|
||
# 鼠标配置
|
||
mouse_config_box = ttk.LabelFrame(debug_container, text="鼠标配置")
|
||
mouse_config_box.pack(fill=X, padx=10, pady=(0, 10))
|
||
|
||
mouse_r1 = ttk.Frame(mouse_config_box)
|
||
mouse_r1.pack(fill=X, padx=10, pady=(10, 8))
|
||
ttk.Label(mouse_r1, text="滑动速度(毫秒):").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
mouse_r1,
|
||
from_=100,
|
||
to=2000,
|
||
increment=50,
|
||
textvariable=vars_["swipe_duration_ms_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(mouse_r1, text="(滑动持续时间,默认600ms,值越大滑动越慢)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
mouse_r2 = ttk.Frame(mouse_config_box)
|
||
mouse_r2.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(mouse_r2, text="上滑起始Y坐标:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
mouse_r2,
|
||
from_=400,
|
||
to=2000,
|
||
increment=50,
|
||
textvariable=vars_["swipe_up_start_y_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(mouse_r2, text="结束Y坐标:").pack(side=LEFT, padx=(10, 0))
|
||
ttk.Spinbox(
|
||
mouse_r2,
|
||
from_=200,
|
||
to=1800,
|
||
increment=50,
|
||
textvariable=vars_["swipe_up_end_y_var"],
|
||
width=6,
|
||
).pack(side=LEFT)
|
||
ttk.Label(mouse_r2, text="(基准1080x2400,默认1200→600,距离600px)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
# 阶段诊断时间参数(用于调试)
|
||
diag_time_box = ttk.LabelFrame(debug_container, text="阶段诊断时间参数")
|
||
diag_time_box.pack(fill=X, padx=10, pady=(0, 10))
|
||
diag_time_r1 = ttk.Frame(diag_time_box)
|
||
diag_time_r1.pack(fill=X, padx=10, pady=(10, 6))
|
||
ttk.Label(diag_time_r1, text="最大诊断时间(秒):").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
diag_time_r1,
|
||
from_=1.0,
|
||
to=60.0,
|
||
increment=1.0,
|
||
textvariable=vars_["stage_diag_max_time_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(diag_time_r1, text="每步最大耗时(秒):").pack(side=LEFT, padx=(12, 0))
|
||
ttk.Spinbox(
|
||
diag_time_r1,
|
||
from_=0.5,
|
||
to=30.0,
|
||
increment=0.5,
|
||
textvariable=vars_["stage_diag_max_step_time_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(diag_time_r1, text="(用于调试,延长检测时间)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
diag_time_r2 = ttk.Frame(diag_time_box)
|
||
diag_time_r2.pack(fill=X, padx=10, pady=(0, 6))
|
||
ttk.Checkbutton(
|
||
diag_time_r2, text="详细阶段诊断日志", variable=vars_["stage_diag_verbose_var"]
|
||
).pack(side=LEFT)
|
||
ttk.Checkbutton(
|
||
diag_time_r2, text="启用OCR模式1(二值化)", variable=vars_["enable_ocr_mode1_var"]
|
||
).pack(side=LEFT, padx=(20, 0))
|
||
diag_time_r2b = ttk.Frame(diag_time_box)
|
||
diag_time_r2b.pack(fill=X, padx=10, pady=(0, 6))
|
||
ttk.Checkbutton(
|
||
diag_time_r2b,
|
||
text="启用福袋模板匹配",
|
||
variable=vars_["fudai_template_match_enabled_var"],
|
||
).pack(side=LEFT)
|
||
diag_time_r3 = ttk.Frame(diag_time_box)
|
||
diag_time_r3.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(diag_time_r3, text="福袋模板匹配阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
diag_time_r3,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["fudai_template_match_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(diag_time_r3, text="(0.0-1.0,彩色匹配)").pack(side=LEFT, padx=(6, 0))
|
||
|
||
diag_time_r3b = ttk.Frame(diag_time_box)
|
||
diag_time_r3b.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(diag_time_r3b, text="福袋详情页模板匹配阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
diag_time_r3b,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["fudai_detail_template_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(
|
||
diag_time_r3b, text="(0.0-1.0,默认0.7,区域(398,894)-(658,1179))"
|
||
).pack(side=LEFT, padx=(6, 0))
|
||
|
||
diag_time_r4 = ttk.Frame(diag_time_box)
|
||
diag_time_r4.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(diag_time_r4, text="开奖页红色占比阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
diag_time_r4,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["lucky_draw_red_ratio_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(diag_time_r4, text="(默认0.90,≥此占比判定开奖页)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
# 更多模板匹配阈值
|
||
diag_time_r5 = ttk.Frame(diag_time_box)
|
||
diag_time_r5.pack(fill=X, padx=10, pady=(0, 6))
|
||
ttk.Label(diag_time_r5, text="优惠券模板匹配阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
diag_time_r5,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["coupon_template_match_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(diag_time_r5, text="(默认0.75,用于检测优惠券弹窗)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
# 像素检测阈值
|
||
pixel_detect_box = ttk.LabelFrame(debug_container, text="像素检测阈值")
|
||
pixel_detect_box.pack(fill=X, padx=10, pady=(0, 10))
|
||
|
||
pixel_switch_r0 = ttk.Frame(pixel_detect_box)
|
||
pixel_switch_r0.pack(fill=X, padx=10, pady=(10, 6))
|
||
for label, var_name in (
|
||
("福袋icon", "pixel_detect_fudai_icon_enabled_var"),
|
||
("优惠券", "pixel_detect_coupon_popup_enabled_var"),
|
||
("购物红包(默认关)", "pixel_detect_shopping_redpacket_enabled_var"),
|
||
("开奖结果", "pixel_detect_lottery_result_enabled_var"),
|
||
):
|
||
ttk.Checkbutton(pixel_switch_r0, text=label, variable=vars_[var_name]).pack(
|
||
side=LEFT, padx=(0, 10)
|
||
)
|
||
|
||
pixel_switch_r1 = ttk.Frame(pixel_detect_box)
|
||
pixel_switch_r1.pack(fill=X, padx=10, pady=(0, 6))
|
||
for label, var_name in (
|
||
("参与按钮", "pixel_detect_attend_button_enabled_var"),
|
||
("粉丝团", "pixel_detect_fansclub_join_enabled_var"),
|
||
("福袋详情", "pixel_detect_fudai_detail_enabled_var"),
|
||
("直播间", "pixel_detect_live_room_enabled_var"),
|
||
):
|
||
ttk.Checkbutton(pixel_switch_r1, text=label, variable=vars_[var_name]).pack(
|
||
side=LEFT, padx=(0, 10)
|
||
)
|
||
|
||
ocr_switch_r0 = ttk.Frame(pixel_detect_box)
|
||
ocr_switch_r0.pack(fill=X, padx=10, pady=(0, 10))
|
||
for label, var_name in (
|
||
("开奖结果OCR", "ocr_lottery_result_enabled_var"),
|
||
("优惠券OCR", "ocr_coupon_popup_enabled_var"),
|
||
("购物红包OCR(默认关)", "ocr_shopping_redpacket_enabled_var"),
|
||
("页面OCR", "ocr_stage_page_enabled_var"),
|
||
):
|
||
ttk.Checkbutton(ocr_switch_r0, text=label, variable=vars_[var_name]).pack(
|
||
side=LEFT, padx=(0, 10)
|
||
)
|
||
|
||
pixel_r1 = ttk.Frame(pixel_detect_box)
|
||
pixel_r1.pack(fill=X, padx=10, pady=(0, 6))
|
||
ttk.Label(pixel_r1, text="参与按钮红色占比阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
pixel_r1,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["attend_button_red_ratio_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(pixel_r1, text="(默认0.25,用于检测参与按钮)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
pixel_r2 = ttk.Frame(pixel_detect_box)
|
||
pixel_r2.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(pixel_r2, text="粉丝团加入红色占比阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
pixel_r2,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["fansclub_join_red_ratio_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(pixel_r2, text="(默认0.25,用于检测粉丝团加入按钮)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
pixel_r3 = ttk.Frame(pixel_detect_box)
|
||
pixel_r3.pack(fill=X, padx=10, pady=(0, 10))
|
||
ttk.Label(pixel_r3, text="购物红包背景红色占比阈值:").pack(side=LEFT)
|
||
ttk.Spinbox(
|
||
pixel_r3,
|
||
from_=0.0,
|
||
to=1.0,
|
||
increment=0.01,
|
||
textvariable=vars_["shopping_redpacket_red_ratio_threshold_var"],
|
||
width=8,
|
||
).pack(side=LEFT)
|
||
ttk.Label(pixel_r3, text="(默认0.15,用于检测购物红包弹窗背景)").pack(
|
||
side=LEFT, padx=(6, 0)
|
||
)
|
||
|
||
return debug_tab
|