feat: Enhance OCR functionality and template matching for 福袋 detection

- Updated `config.json` to include new settings for `enable_ocr_mode1` and `fudai_template_match_threshold`.
- Refactored `douyin_detection.py` to implement template matching for 福袋 detection, replacing the previous pixel-based method.
- Improved error handling and logging for template matching operations.
- Added GUI options for enabling OCR mode and adjusting template matching threshold.
- Enhanced command-line interface to support new OCR and template matching parameters.
This commit is contained in:
Your Name committed 2025-12-19 14:11:16 +08:00
1 parent 836a31d817
commit 0163f27318
12 files changed
+472 -210

No files matched your search

+17 -1
View File
@@ -79,7 +79,7 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
p.add_argument("--device-id", default="", help="ADB 设备 ID(为空则自动选择)")
p.add_argument("--y-pianyi", type=int, default=0, help="y 轴偏移(通常 -50~50)")
p.add_argument("--needswitch", action="store_true", help="是否允许上划切换直播间")
p.add_argument("--wait-minutes", type=int, default=5, help="倒计时超过该分钟则切换(needswitch 生效)")
p.add_argument("--wait-minutes", type=int, default=0, help="运行时长(分钟),0或负数表示无限运行,默认0(无限运行)")
p.add_argument("--test-yanghao-flow", action="store_true", help="测试:只执行一次推荐页养号流程并退出")
p.add_argument("--test-yanghao-flow-seconds", type=int, default=10, help="测试:推荐页养号停留秒数")
@@ -115,6 +115,9 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
p.add_argument("--auto-join-fansclub", action="store_true", help="自动尝试加入粉丝团(可能消耗钻石)")
p.add_argument("--fansclub-fail-action", choices=["stay", "switch"], default=None,
help="粉丝团门槛无法处理时:stay=停留当前直播间;switch=切换下一个")
p.add_argument("--enable-ocr-mode1", action="store_true", help="启用OCR模式1(二值化模式,默认关闭)")
p.add_argument("--disable-ocr-mode1", action="store_true", help="禁用OCR模式1(默认已禁用)")
p.add_argument("--fudai-template-threshold", type=float, default=None, help="福袋模板匹配阈值(0.0-1.0,默认0.7)")
return p.parse_args(argv)
@@ -258,6 +261,19 @@ def main(argv: list[str]) -> int:
analyser.fudai_find_max_attempts = max(1, int(args.fudai_find_max_attempts))
except Exception:
pass
# OCR模式1开关(命令行优先)
if getattr(args, "enable_ocr_mode1", False):
analyser.enable_ocr_mode1 = True
if getattr(args, "disable_ocr_mode1", False):
analyser.enable_ocr_mode1 = False
# 福袋模板匹配阈值(命令行优先)
if getattr(args, "fudai_template_threshold", None) is not None:
try:
threshold = float(args.fudai_template_threshold)
if 0.0 <= threshold <= 1.0:
analyser.fudai_template_match_threshold = threshold
except Exception:
pass
device_id = args.device_id.strip() if args.device_id else ""
if not device_id: