AGENTS.md 更新 pipeline 描述匹配重构后的函数结构

This commit is contained in:
spdis
2026-06-13 14:08:09 +08:00
parent 54a9915bf5
commit 08f87f6050
+16 -11
View File
@@ -96,17 +96,22 @@ All config is via single-value text files in the working directory:
### Per-frame pipeline in `CameraHandler()` ([`src/camera.cpp`](file:///D:\PPPProgram\smartcar\smartcar2\src\camera.cpp))
1. **Capture frame** — 640×480 MJPEG → `cv::imdecode(IMREAD_REDUCED_COLOR_4)` → 1/4 decode to 320×240 BGR
2. **Save image** (debug mode only, when `./saveImg` = 1)
3. **Vision line tracking** — resize to 80×60 → HSV dual-channel Otsu → floodFill → longest-run search → `left_line[60]`, `right_line[60]`, `mid_line[60]`
4. **Model inference** — every 2nd frame, Mild v12 model at 160×120, 4 classes: cone(0) / red light(1) / green light(2) / zebra(3)
5. **Zebra state machine** — NORMAL → STOP(4s) → COOLDOWN(5s) → NORMAL, with debounce (5 frames min, far-enough cy check)
6. **Traffic light state machine** — TL_NORMAL → TL_STOP (red≥3 frames) → TL_WAIT_GREEN (red gone) → TL_NORMAL (green≥3 frames)
7. **Cone avoidance** — confirmed cone detection deforms midline to steer away, with hold-frames decay after cone disappears
8. **Steering servo** — deadband-filtered proportional control via PWM
9. **Motor control** — open-loop duty cycle with curve slowdown in turns; encoder brake on zebra/red-light stop
10. **LCD rendering**`/dev/fb0` mmap, RGB565 conversion, bounding boxes + state indicator overlay
11. **FPS logging** — every 15 frames, prints per-stage timing
CameraHandler 现已拆分为多个函数,主函数 ~40 行仅做编排:
```cpp
CameraHandler()
capture_frame() // 1. MJPG 取帧 → 1/4解码 320×240 BGR
save_image_if_requested() // 2. 保存帧 (debug)
image_main() // 3. 视觉巡线 (80×60 HSV-Otsu-FloodFill)
run_model_inference() // 4. Mild v12 每2帧推理 (160×120, 4类)
zebra_process() // 5a. 斑马线去抖 + Z_STOP(4s)/Z_COOLDOWN(5s)
traffic_light_process() // 5b. 红绿灯 TL_NORMAL→TL_STOP→TL_WAIT_GREEN
cone_detect_and_deform() // 5c. 锥桶检测 + 中线变形 + 保持衰减
steering_update() // 6. 舵机比例控制 (deadband过滤)
motor_update() // 7. 电机开环PWM + 编码器刹车 + 弯道减速
lcd_render() // 8. LCD RGB565渲染 (边界线+检测框+状态)
fps_log() // 9. 每15帧打印分步耗时
```
### Motor control details