duan8Detection/ROI/README.md
2026-01-07 15:40:08 +08:00

69 lines
1.7 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.

# ROI区域过滤验证工具
## 项目结构
```
ROI/
├── roi_filter.py # ROI过滤核心模块
├── validate_roi_setup.py # ROI设置验证工具
├── test_roi_logic.py # ROI逻辑测试
├── test_roi_rtsp.py # RTSP流测试含GUI
└── README.md # 本说明文档
```
## 验证结果
**ROI设置验证成功!**
- 配置文件加载: 正常
- ROI区域定义: 正常 (2个区域)
- 坐标过滤功能: 正常
- RTSP流测试: 正常
## ROI区域配置
当前配置了以下ROI区域
1. **control_lever_area** (控制摇杆区域)
- 坐标范围: (0.10, 0.70) -> (0.30, 0.90)
- 状态: 启用
2. **valve_area** (阀门区域)
- 坐标范围: (0.70, 0.60) -> (0.80, 0.80)
- 状态: 启用
## 使用方法
### 1. 验证ROI设置
```bash
python validate_roi_setup.py
```
### 2. 在d8_5.py中集成ROI过滤
```python
from ROI.roi_filter import ROIManager
# 初始化ROI管理器
roi_manager = ROIManager("../config.yaml")
# 在检测循环中应用过滤
filtered_detections = roi_manager.filter_detections(detections, frame_width, frame_height)
```
### 3. 修改ROI配置
编辑项目根目录下的 `config.yaml` 文件,修改 `roi_filter` 部分:
```yaml
roi_filter:
enabled: true
regions:
- name: "区域名称"
x_min: 0.1 # X坐标最小值 (0-1)
x_max: 0.3 # X坐标最大值 (0-1)
y_min: 0.7 # Y坐标最小值 (0-1)
y_max: 0.9 # Y坐标最大值 (0-1)
description: "区域描述"
enabled: true # 是否启用
```
## 验证说明
- 红色矩形框表示ROI区域
- 在ROI区域内的检测目标将被过滤掉
- 可通过修改配置文件动态调整ROI区域