Initial commit
This commit is contained in:
112
README.md
Normal file
112
README.md
Normal file
@ -0,0 +1,112 @@
|
||||
# 木条检测与分类 Python 接口示例
|
||||
|
||||
本项目提供完整的 Python 示例,用于图像中木条数量检测、存在性判定以及 NG 木条异常分类。
|
||||
它支持:
|
||||
- 基于 RKNNLite 的木条检测
|
||||
- NG/OK 木条判定
|
||||
- NG 木条异常类型分类
|
||||
- 简单接口调用,支持本地图片推理
|
||||
|
||||
---
|
||||
|
||||
## 目录结构
|
||||
|
||||
wood_detection/
|
||||
├── wood_detect/
|
||||
│ ├── wood_detect.py # 木条数量检测接口
|
||||
│ └── wood_detect.rknn # RKNN模型文件
|
||||
├── wood_exist/
|
||||
│ ├── wood_exist.py # 木条存在性判定接口
|
||||
│ └── wood_exist_cls.rknn # RKNN模型文件
|
||||
├── wood_ng/
|
||||
│ ├── wood_ng.py # NG木条异常分类接口
|
||||
│ └── wood_ng_cls.rknn # RKNN模型文件
|
||||
└── README.md # 说明文档
|
||||
---
|
||||
|
||||
## 配置
|
||||
|
||||
### 安装依赖
|
||||
```bash
|
||||
pip install opencv-python numpy rknnlite
|
||||
|
||||
```
|
||||
|
||||
## 接口说明
|
||||
|
||||
### 1. 木条数量检测
|
||||
|
||||
函数:detect_wood(img: np.ndarray) -> int
|
||||
|
||||
参数:
|
||||
|
||||
img:BGR格式图像 (np.ndarray)
|
||||
|
||||
返回值:
|
||||
|
||||
检测到的木条数量 (int)
|
||||
|
||||
示例:
|
||||
|
||||
#### 函数调用
|
||||
|
||||
```python
|
||||
import cv2
|
||||
from wood_detect.wood_detect import detect_wood
|
||||
|
||||
img = cv2.imread("1.jpg")
|
||||
result = detect_wood(img)
|
||||
print(f"检测到木条数量: {result}")
|
||||
|
||||
```
|
||||
|
||||
### 2. 木条存在性判定
|
||||
|
||||
函数:classify_wood_exist(img: np.ndarray) -> int
|
||||
|
||||
参数:
|
||||
|
||||
img:BGR格式图像 (np.ndarray)
|
||||
|
||||
返回值:
|
||||
|
||||
整数结果,对应木条状态(int: 存在结果(0 / 1))
|
||||
|
||||
示例:
|
||||
|
||||
```python
|
||||
import cv2
|
||||
from wood_exist.wood_exist import classify_wood_exist, CLASS_NAMES
|
||||
|
||||
img = cv2.imread("1.png")
|
||||
result = classify_wood_exist(img)
|
||||
print(f"木条存在性判定: {result}")
|
||||
|
||||
```
|
||||
|
||||
### 3. NG 木条异常分类
|
||||
|
||||
函数:classify_wood_ng(img: np.ndarray) -> int
|
||||
|
||||
参数:
|
||||
|
||||
img:BGR格式图像 (np.ndarray)
|
||||
|
||||
返回值:
|
||||
|
||||
整数结果,对应 NG木条(int: NG结果(0 / 1))
|
||||
|
||||
示例:
|
||||
|
||||
```python
|
||||
import cv2
|
||||
from wood_ng.wood_ng import classify_wood_ng, CLASS_NAMES
|
||||
|
||||
img = cv2.imread("1.png")
|
||||
result = classify_wood_ng(img)
|
||||
print(f"NG 木条: {result}")
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user