# ly992hash/opencv architecture

> Architecture diagram of the GitHub repository ly992hash/opencv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ly992hash/opencv
- Repository: https://github.com/ly992hash/opencv

## Overview

这是一个基于 PyQt5 和 OpenCV 的视频行人检测桌面应用。主要流程是用户通过主窗口启动摄像头并配置录制或检测选项，摄像头提供帧，检测器按选项识别人脸、行人和车辆，主窗口展示处理结果；也支持对选定媒体进行离线分析并保存输出。README 还提到本地视频回放，播放器实现可见，但摘录未展示主窗口如何打开它。部分主窗口调用和定时录制细节未完整展示，因此图中只保留可确认的连接。

Main entry points: [`ui/main_window.py`](https://github.com/ly992hash/opencv/blob/master/ui/main_window.py) (主窗口), [`core/detector.py`](https://github.com/ly992hash/opencv/blob/master/core/detector.py) (多目标检测器), [`ui/video_player.py`](https://github.com/ly992hash/opencv/blob/master/ui/video_player.py) (视频播放器), [`core/camera.py`](https://github.com/ly992hash/opencv/blob/master/core/camera.py) (摄像头控制)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["桌面界面"]
  node_main["主窗口<br/>[main_window.py]"]
  node_player["视频播放器<br/>[video_player.py]"]
end

subgraph group_capture["采集与录制"]
  node_camera["摄像头控制<br/>[camera.py]"]
end

subgraph group_vision["视觉检测"]
  node_detector["多目标检测器<br/>[detector.py]"]
  node_yolo_model["YOLOv8 权重<br/>[yolov8n.pt]"]
  node_face_model["人脸模型"]
  node_pedestrian_detector["行人检测器"]
end

subgraph group_media["媒体分析与回放"]
  node_analysis_output["分析结果文件"]
  node_video_processor["视频处理器<br/>[video_processor.py]"]
end

node_user(("用户"))
node_camera_device(("摄像头设备"))
node_offline_media["待分析媒体"]

node_user -->|"操作界面"| node_main
node_main -->|"控制采集录制"| node_camera
node_camera -->|"读取视频帧"| node_camera_device
node_main -->|"分析帧"| node_detector
node_detector -->|"加载权重"| node_yolo_model
node_detector -->|"加载模型"| node_face_model
node_main -->|"选择媒体"| node_offline_media
node_main -->|"离线分析帧"| node_detector
node_main -->|"写入分析结果"| node_analysis_output
node_user -.->|"使用播放器"| node_player
node_player -->|"读取视频"| node_offline_media
node_video_processor -.->|"处理媒体"| node_offline_media
node_pedestrian_detector -.->|"加载权重"| node_yolo_model

click node_main "https://github.com/ly992hash/opencv/blob/master/ui/main_window.py"
click node_player "https://github.com/ly992hash/opencv/blob/master/ui/video_player.py"
click node_camera "https://github.com/ly992hash/opencv/blob/master/core/camera.py"
click node_detector "https://github.com/ly992hash/opencv/blob/master/core/detector.py"
click node_yolo_model "https://github.com/ly992hash/opencv/blob/master/yolov8n.pt"
click node_face_model "https://github.com/ly992hash/opencv/blob/master/models/face_detection/res10_300x300_ssd_iter_140000.caffemodel"
click node_video_processor "https://github.com/ly992hash/opencv/blob/master/core/video_processor.py"
click node_pedestrian_detector "https://github.com/ly992hash/opencv/blob/master/core/pedestrian_detector.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_player toneBlue
class node_camera toneAmber
class node_detector,node_yolo_model,node_face_model,node_pedestrian_detector toneMint
class node_analysis_output,node_video_processor toneRose
class node_user,node_camera_device,node_offline_media toneIndigo
```

## Components

### 桌面界面

- [主窗口](https://github.com/ly992hash/opencv/blob/master/ui/main_window.py): `ui/main_window.py`
- [视频播放器](https://github.com/ly992hash/opencv/blob/master/ui/video_player.py): `ui/video_player.py`

### 采集与录制

- [摄像头控制](https://github.com/ly992hash/opencv/blob/master/core/camera.py): `core/camera.py`

### 视觉检测

- [多目标检测器](https://github.com/ly992hash/opencv/blob/master/core/detector.py): `core/detector.py`
- [YOLOv8 权重](https://github.com/ly992hash/opencv/blob/master/yolov8n.pt): `yolov8n.pt`
- [人脸模型](https://github.com/ly992hash/opencv/blob/master/models/face_detection/res10_300x300_ssd_iter_140000.caffemodel): `models/face_detection/res10_300x300_ssd_iter_140000.caffemodel`
- [行人检测器](https://github.com/ly992hash/opencv/blob/master/core/pedestrian_detector.py): `core/pedestrian_detector.py`

### 媒体分析与回放

- **分析结果文件**
- [视频处理器](https://github.com/ly992hash/opencv/blob/master/core/video_processor.py): `core/video_processor.py`

### Other components

- **用户**
- **摄像头设备**
- **待分析媒体**

## Connections

- 用户 → 主窗口: 操作界面
- 主窗口 → 摄像头控制: 控制采集录制
- 摄像头控制 → 摄像头设备: 读取视频帧
- 主窗口 → 多目标检测器: 分析帧
- 多目标检测器 → YOLOv8 权重: 加载权重
- 多目标检测器 → 人脸模型: 加载模型
- 主窗口 → 待分析媒体: 选择媒体
- 主窗口 → 多目标检测器: 离线分析帧
- 主窗口 → 分析结果文件: 写入分析结果
- 用户 → 视频播放器: 使用播放器
- 视频播放器 → 待分析媒体: 读取视频
- 视频处理器 → 待分析媒体: 处理媒体
- 行人检测器 → YOLOv8 权重: 加载权重
