Files
ailai_image_point_diff/detect_bagor35bag/README.md

112 lines
2.3 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.

# RKNN 料袋bag / bag35检测与滚筒控制逻辑
本工程基于 **RKNN 模型** 对流水线上的料袋进行检测与分类(`bag` / `bag35`
并根据检测结果与位置关系判断料袋状态(未到位 / 到位 / 掉出滚筒),
最终执行对应的 **滚筒控制逻辑** 或用于 **纯判断测试**
---
## 一、目录结构
```
detect_bagor35bag/
├── bag3568.rknn
├── detect_bag.py
├── main_bag_judgment.py
├── test_bag_onlyjudgment_withou-motor-contral.py
├── test_image/
└── README.md
```
---
## 二、功能说明
### 料袋检测
- RKNN 推理
- 支持 `bag` / `bag35` 目标检测
- 输出 `cls / conf / min_x` 50kg料包为bag35kg为bag35conf是置信度min_x是判断料包底部距离现在传感器物理位置的距离未到位是负数到位后是正数距离
### 状态判断
| 状态 | 条件 |
|----|----|
| 没有料袋 | min_x is None |
| 料袋未到位 | min_x < THRESHOLD_X |
| 料袋到位 | THRESHOLD_X min_x THRESHOLD_maxX |
| 料包掉出滚筒 | min_x > THRESHOLD_maxX |
```python
THRESHOLD_X = 537 # 到位阈值
THRESHOLD_maxX = 1430 # 掉出滚筒阈值
```
### 滚筒控制规则
- 未检测 / 未到位 → 不动作
- 掉出滚筒 → 停机报警
- 到位:
- bag → 立即停止滚筒
- bag35 → 延时2s → 这里不确定能不能直接正转变反转加了一个停止滚筒→ 反转2s → 停止
---
## 三、依赖安装(已安装)
```bash
pip install opencv-python numpy rknnlite
```
---
## 四、使用方式
### 主程序(含电机控制)
```bash
python main_bag_judgment.py
```
### 仅判断测试(无电机)
```bash
python test_bag_onlyjudgment_withou-motor-contral.py
```
---
## 五、核心接口
### detect_bag
```python
cls, conf, min_x = detect_bag(img) #不可视化图像
cls, conf, min_x, vis_img = detect_bag(img, return_vis=True) #可视化图像
```
### bag_judgment
```python
status_bool, status_text, conf, min_x, vis_img = bag_judgment(img) #不可视化图像+滚筒控制
```
---
## 六、状态文本规范
```
没有料袋
料袋未到位
料袋到位
料包掉出滚筒
```
---
## 七、说明
- 检测与控制逻辑解耦
- 易于扩展新料袋类型
- 支持现场与离线测试