 CodexandClaude Opus 4.7
|
b200002a00
|
refactor(finder): 抽 OpenCV 模板匹配兜底到 finder_template_match (635 → 417)
check_have_fudai_with_ready_screenshot L288-513 是像素检测都失败时的最后
兜底(226 行):cv2.matchTemplate(TM_CCOEFF_NORMED) + minMaxLoc 在
156..269 × 351..451 搜索区域里找 fudai.png 模板。
抽到 douyin/detection/detection_pkg/finder_template_match.py:
- match_template(analyser, pic_new, rx, ry, y_pianyi_val, loop) → (det, x)
- _resolve_template_path 从 path_config / 项目根 assets 解析模板路径
(兜底走 .. 回退,避免推到 detection_pkg/assets)
- _save_search_roi 提取 last_match.png 的保存逻辑
主 finder.py 替换为 7 行委托,从 635 → 417 行。
新增 9 个单元测试覆盖:
- _resolve_template_path:用 path_config / 兜底
- 早出条件:模板路径不存在 / cv2.imread 返回 None / 搜索区域无效
- 命中:max_val>=threshold 时 detected_x 是 1080 基准
- 不命中:max_val<threshold 时返回 False
- 模板太大:cv2.resize 被调用
- cv2 不可用时安全返回 False
1345 passed (+9)。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-23 02:26:49 +08:00 |
|