Actuators/README.md

80 lines
2.2 KiB
Markdown
Raw Permalink 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.

# 制动器角度读取工具
读取视频中的制动器弯曲角度。手动点击标记点,计算 ∠M2-O-M偏离角
## 安装
```bash
conda create -n actuator python=3.10 -y
conda activate actuator
pip install opencv-python PyQt6
```
## 运行
```bash
python main.py static/test.mp4
```
> Wayland 环境需加:`QT_QPA_PLATFORM=xcb python main.py static/test.mp4`
> 光标变小可尝试:`QT_SCALE_FACTOR=1 python main.py static/test.mp4`
## 使用流程
### 手动模式
1. **文件 → 打开视频**
2. 在首帧依次点击 **O**(圆心)、**M**(初始尾端参考)
3. 拖动滑块到目标帧,点击 **M2**(当前尾端),右侧显示角度
### 测量模式
1. 首帧选好 O 和 M
2. 点击 **「开始测量」**
3. 逐帧点击 M2每点完一帧自动进下一帧
4. 点击 **「停止测量」** 或跑完全部帧后自动停止
5. **「导出测量数据 (CSV)」** 保存角度 + 每帧标注截图
### 方向矫正
勾选「翻转角度符号」切换角度正负号。
## 项目结构
```
Actuator/
├── main.py # PyQt6 GUI 主程序
├── requirements.txt # 依赖
├── actuator/
│ ├── __init__.py
│ ├── angle_calc.py # 角度 & 曲率计算
│ ├── automation.py # 自动化接口(手动/自动检测器)
│ └── video_reader.py # 视频逐帧读取
└── static/
└── test.mp4 # 测试视频
```
## 自动化接口
`actuator/automation.py` 提供可扩展的检测器:
- `PointDetector` — 抽象基类,实现 `detect(frame) -> [(x,y), ...]` 即可接入
- `ColorBlobDetector` — 基于 HSV 颜色范围的自动检测(已实现)
- `ActuatorAnalyzer` — 批量分析全视频的封装类
```python
from actuator import ActuatorAnalyzer, ColorBlobDetector
analyzer = ActuatorAnalyzer("video.mp4")
analyzer.set_reference(o=(100, 200), m=(100, 100))
analyzer.set_detector(ColorBlobDetector())
results = analyzer.analyze_all_frames()
```
## 角度定义
∠M2-O-M以 O圆心为顶点M初始尾端为参考方向
M2当前尾端为移动方向两者之间的夹角。
正角度 = 屏幕顺时针方向。