feat: expose fudai region coordinates in gui

This commit is contained in:
Your Name committed 2026-06-03 20:29:10 +08:00
1 parent bcc4d1151f
commit 4797fa046e
17 files changed
+1044 -119

No files matched your search

+88
View File
@@ -14,6 +14,86 @@ 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)
@@ -303,6 +383,14 @@ def setup_debug_tab(parent: ttk.Notebook, *, vars_: Dict[str, tk.Variable]) -> t
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))