Add shopping red packet detection tests and sample image
- Implemented a test script for shopping red packet detection using pixel analysis and OCR. - Created a sample image to simulate a shopping red packet for testing purposes. - Added functions to test pixel detection, coordinate definitions, and OCR keyword matching. - Included detailed print statements for test results and summaries.
This commit is contained in:
1 parent
b3011dd9ce
commit
fb0c07c91a
30 files changed
+1269
-319
No files matched your search
+162
-35
@@ -440,12 +440,27 @@ def main():
|
||||
high_value_fudai_after_action_var = tk.StringVar(
|
||||
value=str(cfg.get("high_value_fudai_after_action", "continue") or "continue")
|
||||
)
|
||||
high_value_fudai_poll_before_seconds_var = tk.DoubleVar(
|
||||
value=float(cfg.get("high_value_fudai_poll_before_seconds", 10.0) or 10.0)
|
||||
)
|
||||
high_value_room_revisit_enabled_var = tk.BooleanVar(
|
||||
value=bool(cfg.get("high_value_room_revisit_enabled", True))
|
||||
)
|
||||
high_value_room_revisit_only_current_run_var = tk.BooleanVar(
|
||||
value=bool(cfg.get("high_value_room_revisit_only_current_run", False))
|
||||
)
|
||||
high_value_room_revisit_min_interval_seconds_var = tk.IntVar(
|
||||
value=int(cfg.get("high_value_room_revisit_min_interval_seconds", 300))
|
||||
)
|
||||
high_value_room_revisit_max_per_run_var = tk.IntVar(
|
||||
value=int(cfg.get("high_value_room_revisit_max_per_run", 5))
|
||||
)
|
||||
high_value_room_revisit_min_prize_value_var = tk.DoubleVar(
|
||||
value=float(cfg.get("high_value_room_revisit_min_prize_value", 0.0))
|
||||
)
|
||||
high_value_room_revisit_max_age_days_var = tk.IntVar(
|
||||
value=int(cfg.get("high_value_room_revisit_max_age_days", 30))
|
||||
)
|
||||
reservation_back_verify_enabled_var = tk.BooleanVar(
|
||||
value=bool(cfg.get("reservation_back_verify_enabled", True))
|
||||
)
|
||||
@@ -545,18 +560,10 @@ def main():
|
||||
cfg.get("yanghao_fav_template_path", "assets/fav.png") or "assets/fav.png"
|
||||
)
|
||||
)
|
||||
yg_like_icon_x_var = tk.IntVar(
|
||||
value=int(cfg.get("yanghao_like_icon_x", 0) or 0)
|
||||
)
|
||||
yg_like_icon_y_var = tk.IntVar(
|
||||
value=int(cfg.get("yanghao_like_icon_y", 0) or 0)
|
||||
)
|
||||
yg_fav_icon_x_var = tk.IntVar(
|
||||
value=int(cfg.get("yanghao_fav_icon_x", 0) or 0)
|
||||
)
|
||||
yg_fav_icon_y_var = tk.IntVar(
|
||||
value=int(cfg.get("yanghao_fav_icon_y", 0) or 0)
|
||||
)
|
||||
yg_like_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_x", 0) or 0))
|
||||
yg_like_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_like_icon_y", 0) or 0))
|
||||
yg_fav_icon_x_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_x", 0) or 0))
|
||||
yg_fav_icon_y_var = tk.IntVar(value=int(cfg.get("yanghao_fav_icon_y", 0) or 0))
|
||||
yg_after_dwell_direction_var = tk.StringVar(
|
||||
value=str(cfg.get("yanghao_after_dwell_swipe_direction", "up") or "up")
|
||||
)
|
||||
@@ -995,6 +1002,59 @@ def main():
|
||||
res_r4, text="仅当前运行", variable=high_value_room_revisit_only_current_run_var
|
||||
).pack(side=LEFT, padx=(20, 0))
|
||||
|
||||
# 高价值房间回访详细参数
|
||||
res_r4a = ttk.Frame(reservation_box)
|
||||
res_r4a.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(res_r4a, text="重访最小间隔(秒):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
res_r4a,
|
||||
from_=60,
|
||||
to=3600,
|
||||
textvariable=high_value_room_revisit_min_interval_seconds_var,
|
||||
width=8,
|
||||
).pack(side=LEFT, padx=(0, 20))
|
||||
ttk.Label(res_r4a, text="每次运行最大次数:").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
res_r4a,
|
||||
from_=1,
|
||||
to=20,
|
||||
textvariable=high_value_room_revisit_max_per_run_var,
|
||||
width=5,
|
||||
).pack(side=LEFT, padx=(0, 20))
|
||||
|
||||
res_r4b = ttk.Frame(reservation_box)
|
||||
res_r4b.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(res_r4b, text="最低奖品价值(元):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
res_r4b,
|
||||
from_=0.0,
|
||||
to=10000.0,
|
||||
textvariable=high_value_room_revisit_min_prize_value_var,
|
||||
width=8,
|
||||
).pack(side=LEFT, padx=(0, 20))
|
||||
ttk.Label(res_r4b, text="最大年龄(天):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
res_r4b,
|
||||
from_=1,
|
||||
to=365,
|
||||
textvariable=high_value_room_revisit_max_age_days_var,
|
||||
width=5,
|
||||
).pack(side=LEFT, padx=(0, 20))
|
||||
|
||||
# 开奖前轮询时间
|
||||
res_r4b = ttk.Frame(reservation_box)
|
||||
res_r4b.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(res_r4b, text="开奖前轮询时间(秒):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
res_r4b,
|
||||
from_=0.0,
|
||||
to=60.0,
|
||||
increment=1.0,
|
||||
textvariable=high_value_fudai_poll_before_seconds_var,
|
||||
width=6,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(res_r4b, text="(开奖前N秒开始轮询预约)").pack(side=LEFT, padx=(6, 0))
|
||||
|
||||
# 预约回退校验
|
||||
res_r5 = ttk.Frame(reservation_box)
|
||||
res_r5.pack(fill=X, padx=10, pady=(0, 8))
|
||||
@@ -1093,11 +1153,21 @@ def main():
|
||||
yg1b.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(yg1b, text="检测动作后停留(秒):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
yg1b, from_=0.0, to=120.0, increment=1.0, textvariable=yg_dwell_on_action_min_var, width=6
|
||||
yg1b,
|
||||
from_=0.0,
|
||||
to=120.0,
|
||||
increment=1.0,
|
||||
textvariable=yg_dwell_on_action_min_var,
|
||||
width=6,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(yg1b, text="~").pack(side=LEFT, padx=(6, 6))
|
||||
ttk.Spinbox(
|
||||
yg1b, from_=0.0, to=120.0, increment=1.0, textvariable=yg_dwell_on_action_max_var, width=6
|
||||
yg1b,
|
||||
from_=0.0,
|
||||
to=120.0,
|
||||
increment=1.0,
|
||||
textvariable=yg_dwell_on_action_max_var,
|
||||
width=6,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(yg1b, text="(随机范围)").pack(side=LEFT, padx=(6, 0))
|
||||
|
||||
@@ -1809,12 +1879,27 @@ def main():
|
||||
high_value_fudai_after_action_var.set(
|
||||
str(cfg.get("high_value_fudai_after_action", "continue") or "continue")
|
||||
)
|
||||
high_value_fudai_poll_before_seconds_var.set(
|
||||
float(cfg.get("high_value_fudai_poll_before_seconds", 10.0) or 10.0)
|
||||
)
|
||||
high_value_room_revisit_enabled_var.set(
|
||||
bool(cfg.get("high_value_room_revisit_enabled", True))
|
||||
)
|
||||
high_value_room_revisit_only_current_run_var.set(
|
||||
bool(cfg.get("high_value_room_revisit_only_current_run", False))
|
||||
)
|
||||
high_value_room_revisit_min_interval_seconds_var.set(
|
||||
int(cfg.get("high_value_room_revisit_min_interval_seconds", 300))
|
||||
)
|
||||
high_value_room_revisit_max_per_run_var.set(
|
||||
int(cfg.get("high_value_room_revisit_max_per_run", 5))
|
||||
)
|
||||
high_value_room_revisit_min_prize_value_var.set(
|
||||
float(cfg.get("high_value_room_revisit_min_prize_value", 0.0))
|
||||
)
|
||||
high_value_room_revisit_max_age_days_var.set(
|
||||
int(cfg.get("high_value_room_revisit_max_age_days", 30))
|
||||
)
|
||||
reservation_back_verify_enabled_var.set(
|
||||
bool(cfg.get("reservation_back_verify_enabled", True))
|
||||
)
|
||||
@@ -1977,8 +2062,12 @@ def main():
|
||||
yg_like_prob_var.set(float(cfg.get("yanghao_like_prob", 0.0) or 0.0))
|
||||
yg_fav_prob_var.set(float(cfg.get("yanghao_fav_prob", 0.0) or 0.0))
|
||||
yg_comment_prob_var.set(float(cfg.get("yanghao_comment_prob", 0.0) or 0.0))
|
||||
yg_dwell_on_action_min_var.set(float(cfg.get("yanghao_dwell_on_action_min_seconds", 5) or 5))
|
||||
yg_dwell_on_action_max_var.set(float(cfg.get("yanghao_dwell_on_action_max_seconds", 30) or 30))
|
||||
yg_dwell_on_action_min_var.set(
|
||||
float(cfg.get("yanghao_dwell_on_action_min_seconds", 5) or 5)
|
||||
)
|
||||
yg_dwell_on_action_max_var.set(
|
||||
float(cfg.get("yanghao_dwell_on_action_max_seconds", 30) or 30)
|
||||
)
|
||||
yg_icon_roi_size_var.set(int(cfg.get("yanghao_icon_roi_size", 240) or 240))
|
||||
yg_icon_match_threshold_var.set(
|
||||
float(cfg.get("yanghao_icon_match_threshold", 0.72) or 0.72)
|
||||
@@ -2089,12 +2178,27 @@ def main():
|
||||
cfg2["high_value_fudai_after_action"] = str(
|
||||
high_value_fudai_after_action_var.get() or "continue"
|
||||
).lower()
|
||||
cfg2["high_value_fudai_poll_before_seconds"] = float(
|
||||
high_value_fudai_poll_before_seconds_var.get() or 10.0
|
||||
)
|
||||
cfg2["high_value_room_revisit_enabled"] = bool(
|
||||
high_value_room_revisit_enabled_var.get()
|
||||
)
|
||||
cfg2["high_value_room_revisit_only_current_run"] = bool(
|
||||
high_value_room_revisit_only_current_run_var.get()
|
||||
)
|
||||
cfg2["high_value_room_revisit_min_interval_seconds"] = int(
|
||||
high_value_room_revisit_min_interval_seconds_var.get()
|
||||
)
|
||||
cfg2["high_value_room_revisit_max_per_run"] = int(
|
||||
high_value_room_revisit_max_per_run_var.get()
|
||||
)
|
||||
cfg2["high_value_room_revisit_min_prize_value"] = float(
|
||||
high_value_room_revisit_min_prize_value_var.get()
|
||||
)
|
||||
cfg2["high_value_room_revisit_max_age_days"] = int(
|
||||
high_value_room_revisit_max_age_days_var.get()
|
||||
)
|
||||
cfg2["reservation_back_verify_enabled"] = bool(
|
||||
reservation_back_verify_enabled_var.get()
|
||||
)
|
||||
@@ -2245,8 +2349,12 @@ def main():
|
||||
cfg2["yanghao_like_prob"] = float(yg_like_prob_var.get() or 0.0)
|
||||
cfg2["yanghao_fav_prob"] = float(yg_fav_prob_var.get() or 0.0)
|
||||
cfg2["yanghao_comment_prob"] = float(yg_comment_prob_var.get() or 0.0)
|
||||
cfg2["yanghao_dwell_on_action_min_seconds"] = float(yg_dwell_on_action_min_var.get() or 5)
|
||||
cfg2["yanghao_dwell_on_action_max_seconds"] = float(yg_dwell_on_action_max_var.get() or 30)
|
||||
cfg2["yanghao_dwell_on_action_min_seconds"] = float(
|
||||
yg_dwell_on_action_min_var.get() or 5
|
||||
)
|
||||
cfg2["yanghao_dwell_on_action_max_seconds"] = float(
|
||||
yg_dwell_on_action_max_var.get() or 30
|
||||
)
|
||||
cfg2["yanghao_icon_roi_size"] = int(yg_icon_roi_size_var.get() or 240)
|
||||
cfg2["yanghao_icon_match_threshold"] = float(
|
||||
yg_icon_match_threshold_var.get() or 0.72
|
||||
@@ -3370,6 +3478,21 @@ def main():
|
||||
high_value_room_revisit_only_current_run=bool(
|
||||
high_value_room_revisit_only_current_run_var.get()
|
||||
),
|
||||
high_value_room_revisit_min_interval_seconds=int(
|
||||
high_value_room_revisit_min_interval_seconds_var.get()
|
||||
),
|
||||
high_value_room_revisit_max_per_run=int(
|
||||
high_value_room_revisit_max_per_run_var.get()
|
||||
),
|
||||
high_value_room_revisit_min_prize_value=float(
|
||||
high_value_room_revisit_min_prize_value_var.get()
|
||||
),
|
||||
high_value_room_revisit_max_age_days=int(
|
||||
high_value_room_revisit_max_age_days_var.get()
|
||||
),
|
||||
high_value_fudai_poll_before_seconds=float(
|
||||
high_value_fudai_poll_before_seconds_var.get() or 10.0
|
||||
),
|
||||
reservation_back_verify_enabled=bool(
|
||||
reservation_back_verify_enabled_var.get()
|
||||
),
|
||||
@@ -3586,13 +3709,15 @@ def main():
|
||||
fudai_result_win = counters.get("fudai_result_win", 0)
|
||||
fudai_order_success = counters.get("fudai_order_success", 0)
|
||||
|
||||
if fudai_seen_unique > 0 or fudai_attend_ok_unique > 0 or fudai_result_win > 0:
|
||||
if (
|
||||
fudai_seen_unique > 0
|
||||
or fudai_attend_ok_unique > 0
|
||||
or fudai_result_win > 0
|
||||
):
|
||||
lines.append("=" * 60)
|
||||
lines.append("快速汇总")
|
||||
lines.append("=" * 60)
|
||||
lines.append(
|
||||
f"识别福袋: {fudai_seen_unique} 个"
|
||||
)
|
||||
lines.append(f"识别福袋: {fudai_seen_unique} 个")
|
||||
lines.append(f"参与成功: {fudai_attend_ok_unique} 次")
|
||||
lines.append(f"中奖次数: {fudai_result_win} 次")
|
||||
lines.append(f"下单成功: {fudai_order_success} 次")
|
||||
@@ -3621,34 +3746,34 @@ def main():
|
||||
fudai_order_success = counters.get("fudai_order_success", 0)
|
||||
|
||||
lines.append(f"福袋识别次数: {fudai_seen_unique}")
|
||||
lines.append(
|
||||
f"打开详情: {fudai_open_detail_unique}"
|
||||
)
|
||||
lines.append(f"打开详情: {fudai_open_detail_unique}")
|
||||
if fudai_seen > 0:
|
||||
open_rate = (fudai_open_detail_unique / fudai_seen_unique) * 100
|
||||
lines.append(f" 打开成功率: {open_rate:.1f}%")
|
||||
|
||||
lines.append(
|
||||
f"点击参与: {fudai_click_attend_unique}"
|
||||
)
|
||||
lines.append(f"点击参与: {fudai_click_attend_unique}")
|
||||
if fudai_open_detail > 0:
|
||||
click_rate = (fudai_click_attend_unique / fudai_open_detail_unique) * 100
|
||||
click_rate = (
|
||||
fudai_click_attend_unique / fudai_open_detail_unique
|
||||
) * 100
|
||||
lines.append(f" 点击率: {click_rate:.1f}%")
|
||||
|
||||
lines.append(
|
||||
f"参与成功: {fudai_attend_ok_unique}"
|
||||
)
|
||||
lines.append(f"参与成功: {fudai_attend_ok_unique}")
|
||||
lines.append(f"参与失败: {fudai_attend_fail}")
|
||||
# 参与成功率应该基于点击参与次数来计算
|
||||
# 因为参与成功可能包括"检测到已参与"的情况(没有点击)
|
||||
if fudai_click_attend_unique > 0:
|
||||
# 通过点击参与成功的次数(不超过点击参与次数)
|
||||
click_attend_success = min(fudai_attend_ok_unique, fudai_click_attend_unique)
|
||||
click_attend_success = min(
|
||||
fudai_attend_ok_unique, fudai_click_attend_unique
|
||||
)
|
||||
success_rate = (click_attend_success / fudai_click_attend_unique) * 100
|
||||
lines.append(f" 参与成功率: {success_rate:.1f}%")
|
||||
# 如果参与成功 > 点击参与,说明有检测到已参与的情况
|
||||
if fudai_attend_ok_unique > fudai_click_attend_unique:
|
||||
detected_already_attended = fudai_attend_ok_unique - fudai_click_attend_unique
|
||||
detected_already_attended = (
|
||||
fudai_attend_ok_unique - fudai_click_attend_unique
|
||||
)
|
||||
lines.append(
|
||||
f" (其中 {detected_already_attended} 次为检测到已参与状态)"
|
||||
)
|
||||
@@ -3681,7 +3806,9 @@ def main():
|
||||
lines.append("")
|
||||
lines.append("效率统计(每小时):")
|
||||
if fudai_seen_unique > 0:
|
||||
lines.append(f" 识别福袋: {fudai_seen_unique / hours:.1f} 个/小时")
|
||||
lines.append(
|
||||
f" 识别福袋: {fudai_seen_unique / hours:.1f} 个/小时"
|
||||
)
|
||||
if fudai_attend_ok_unique > 0:
|
||||
lines.append(
|
||||
f" 参与成功: {fudai_attend_ok_unique / hours:.1f} 次/小时"
|
||||
|
||||
Reference in new issue
Block a user