expose fudai detail thresholds and regions

This commit is contained in:
Your Name committed 2026-06-05 15:36:10 +08:00
1 parent 37a2f94486
commit 9b03556b7d
14 files changed
+293 -18

No files matched your search

+70 -3
View File
@@ -66,6 +66,7 @@ _REGION_SECTIONS = (
("pixel_regions", "coupon_popup", None, "优惠券"),
("pixel_regions", "shopping_redpacket", None, "购物红包"),
("pixel_regions", "fudai_detail_body", None, "详情主体"),
("pixel_regions", "fudai_task_status", None, "任务状态达成"),
("pixel_regions", "live_room_icon_bbox", None, "直播间图标bbox"),
),
),
@@ -82,16 +83,20 @@ def _add_region_editor(parent: ttk.Frame, *, root: str, scope: str, name: str |
row = ttk.Frame(parent)
row.pack(fill=X, padx=10, pady=(0, 4))
ttk.Label(row, text=f"{label}:", width=14).pack(side=LEFT)
inputs = []
for axis in ("x1", "y1", "x2", "y2"):
ttk.Label(row, text=f"{axis}").pack(side=LEFT, padx=(4, 2))
ttk.Spinbox(
widget = ttk.Spinbox(
row,
from_=-9999,
to=9999,
increment=1,
textvariable=vars_[_make_region_var_key(root, scope, name, axis)],
width=6,
).pack(side=LEFT)
)
widget.pack(side=LEFT)
inputs.append(widget)
return inputs
def setup_debug_tab(parent: ttk.Notebook, *, vars_: Dict[str, tk.Variable]) -> ttk.Frame:
@@ -383,13 +388,75 @@ 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))
detail_pixel_box = ttk.LabelFrame(fudai_find_box, text="福袋详情页像素判定")
detail_pixel_box.pack(fill=X, padx=10, pady=(0, 8))
detail_pixel_r1 = ttk.Frame(detail_pixel_box)
detail_pixel_r1.pack(fill=X, padx=10, pady=(8, 6))
ttk.Label(detail_pixel_r1, text="详情主体蓝紫比例阈值:").pack(side=LEFT)
ttk.Spinbox(
detail_pixel_r1,
from_=0.0,
to=1.0,
increment=0.01,
textvariable=vars_["fudai_detail_body_bluepurple_threshold_var"],
width=6,
).pack(side=LEFT)
ttk.Label(detail_pixel_r1, text="暗色比例阈值:").pack(side=LEFT, padx=(20, 0))
ttk.Spinbox(
detail_pixel_r1,
from_=0.0,
to=1.0,
increment=0.01,
textvariable=vars_["fudai_detail_body_dark_threshold_var"],
width=6,
).pack(side=LEFT)
ttk.Label(detail_pixel_r1, text="“达成”形状匹配阈值:").pack(
side=LEFT, padx=(20, 0)
)
ttk.Spinbox(
detail_pixel_r1,
from_=0.0,
to=1.0,
increment=0.01,
textvariable=vars_["fudai_task_status_template_threshold_var"],
width=6,
).pack(side=LEFT)
region_box = ttk.LabelFrame(debug_container, text="福袋坐标配置")
region_box.pack(fill=X, padx=10, pady=(0, 10))
region_toggle_row = ttk.Frame(region_box)
region_toggle_row.pack(fill=X, padx=10, pady=(8, 4))
ttk.Checkbutton(
region_toggle_row,
text="启用坐标调整(默认关闭,避免滚轮误触)",
variable=vars_["region_coords_edit_enabled_var"],
).pack(side=LEFT)
ttk.Label(
region_toggle_row,
text="关闭时下方 OCR / 像素坐标全部只读",
).pack(side=LEFT, padx=(8, 0))
region_widgets = []
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_)
region_widgets.extend(
_add_region_editor(section, root=root, scope=scope, name=name, label=label, vars_=vars_)
)
def _sync_region_editor_state(*_args):
state = "normal" if bool(vars_["region_coords_edit_enabled_var"].get()) else "disabled"
for widget in region_widgets:
try:
widget.configure(state=state)
except Exception:
pass
try:
vars_["region_coords_edit_enabled_var"].trace_add("write", _sync_region_editor_state)
except Exception:
pass
_sync_region_editor_state()
# 鼠标配置
mouse_config_box = ttk.LabelFrame(debug_container, text="鼠标配置")