Files
douyin_guaji-main/docs/AI_PROJECT_SUMMARY.md
T
Your Name 25ed50cc3c feat: Add AI project summary and coordinate constants for Douyin Fudai
- Created AI_PROJECT_SUMMARY.md for quick understanding of project structure, data flow, key interfaces, and verification points.
- Added key modules and data flow overview for automated participation in Douyin Fudai lottery.
- Introduced a JSON schema example for configuration and provided quick validation steps.
- Updated coordinate constants in coords.py for various cropping areas related to Fudai details, ensuring centralized management of coordinates.
- Generated a new actions log file for tracking actions performed by the application.
2026-01-03 00:06:59 +08:00

72 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 项目(AI 友好)摘要 — 抖音福袋挂机
此文件为面向 AI 助手的精简技术摘要,便于快速理解项目结构、数据流、关键接口与运行验证要点。
## 一句概述
- 自动在抖音直播间检测并参与福袋抽奖;基于 ADB 截图、像素检测、模板匹配和 OCR(EasyOCR/PaddleOCR)实现决策与操作。
## 关键模块(短列表)
- `run_cli.py`:CLI 入口,解析参数并启动 `fudai_analyse.fudai_choujiang()`。
- `douyin/core/douyin_fudai.py`(`fudai_analyse`):主调度器(Mixin 组合)。
- `douyin/fudai/douyin_fudai_core.py`:福袋详情解析、并行 OCR、筛选与参与决策。
- `Underlying_Operations.py`:底层设备操作、截图、裁剪、OCR 封装与回退策略。
- `douyin/detection/`:像素检测与模板匹配(阶段诊断)。
- `douyin/reservation/`:高价值预约与回退处理。
- `path_config.py`:统一路径获取(避免硬编码)。
## 数据流(精简)
1. ADB截图 → 保存 `pic/screenshot.png`(原子替换)
2. 裁剪目标区域(`cut_pic`)→ 交给 OCR(`analyse_pic_word`/`analyse_pic_digits`)
3. OCR 文本 → 文本解析(倒计时/价值/人数)
4. 筛选决策(`basic_join_decision`)→ 点击操作(`operation.click`)或预约记录(`state/reservations.json`)
示意(ASCII):
SCREENSHOT -> CUT_PIC -> OCR -> PARSE -> DECIDE -> ACTION
↓ ↓
PIXEL_DETECT STATE
## AI 需要的简洁接口清单(签名 + 单行说明)
- `fudai_analyse.fudai_choujiang(device_id: str, y_pianyi: int, needswitch: bool, wait_minutes: int)` — 启动主循环。
- `fudai_analyse.run_once_basic()` — 单次循环(用于快速验证)。
- `get_fudai_contain(analyser) -> (content, countdown_text, participants, task_count, prize_value_yuan)` — 并行 OCR 获取福袋详情。
- `basic_join_decision(analyser, detail) -> bool` — 根据配置决策是否参与。
- `underlying_operations.get_screenshot(device_id) -> bool` — 获取并写入 `pic/screenshot.png`(原子替换)。
- `underlying_operations.cut_pic(left, top, right, bottom, name)` — 裁剪并保存子图用于 OCR。
- `underlying_operations.analyse_pic_word(picname) -> str` — 对裁剪图运行 OCR 并返回文本。
## 配置(快速 JSON schema 示例)
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"needswitch": {"type":"boolean"},
"min_prize_value_yuan": {"type":"number","minimum":0},
"high_value_fudai_threshold_yuan": {"type":"number","minimum":0},
"debug_captures": {"type":"object"}
},
"required": ["needswitch"]
}
```
## 快速验证(AI 可执行的最小步骤)
1. 在连接设备的情况下,运行单次循环以生成截图并保存裁剪图:
```bash
python run_cli.py --device-id <DEVICE_ID> --wait-minutes 0
```
2. 检查 `pic/` 下的 `screenshot.png` 与裁剪图 (`pic/cut_*`),验证 `福袋价值` 裁剪区域是否为新坐标 (639,1466)-(769,1586)(已在代码中更新)。
## 变更与可检索点
- 已修改:`douyin/fudai/douyin_fudai_core.py` 中 `value_box` 裁剪坐标改为 `(639, 1466, 769, 1586)`。
- 文档新增:本 AI 摘要(此文件)与 `docs/完整技术文档.md` 的扩充。
## 推荐 AI 使用模式
- 若需解释函数,先调用 `semantic search` 在仓库内检索函数定义,然后读取对应文件段落(`path_config.py`、`Underlying_Operations.py`、`douyin/fudai/douyin_fudai_core.py`)。
- 对于 OCR/图像问题,优先让 AI 输出裁剪后的样例截图坐标与 OCR 文本样例,再定位 `analyse_pic_word` 的调用点。
---
文件生成于 2026-01-02,用于 AI 与开发者的快速对接;如需我将该内容合并回 `docs/完整技术文档.md` 的特定位置,我可以继续做这一步。