完成夹具开合判断的代码,更新了rknn3588上完成测试,3568在生产下次去测试的时候再进行测试
This commit is contained in:
58
cls_main/readme.md
Normal file
58
cls_main/readme.md
Normal file
@ -0,0 +1,58 @@
|
||||
# yolov11_cls_inference README
|
||||
|
||||
## 概述
|
||||
该模块用于对米厂输入图像执行二分类推理,用于判断机械臂夹爪是否夹紧。
|
||||
|
||||
类别定义:
|
||||
|
||||
0 → 夹具夹紧 (False)
|
||||
1 → 夹具打开 (True)
|
||||
|
||||
rknn模型只加载一次,复用全局实例,提高推理效率。
|
||||
|
||||
## 调用示例
|
||||
|
||||
您可以直接调用 yolov11_cls_inference 函数,以便集成到其他项目中:
|
||||
|
||||
示例 1: 单张图片推理
|
||||
|
||||
```bash
|
||||
from main_cls import yolov11_cls_inference
|
||||
import cv2
|
||||
|
||||
# 读取图像
|
||||
bgr_image = cv2.imread("11.jpg")
|
||||
rgb_image = cv2.cvtColor(bgr_image, cv2.COLOR_BGR2RGB)
|
||||
|
||||
# 调用推理函数
|
||||
class_id, bool_value = yolov11_cls_inference(
|
||||
model_path="yolov11_cls.rknn",
|
||||
raw_image=rgb_image,
|
||||
target_size=(640, 640)
|
||||
)
|
||||
|
||||
print(f"类别ID: {class_id}, 布尔值: {bool_value}")
|
||||
|
||||
```
|
||||
|
||||
示例 2: 多次推理(复用模型)
|
||||
```bash
|
||||
|
||||
from main_cls import init_rknn_model, yolov11_cls_inference_once
|
||||
import cv2
|
||||
|
||||
# 初始化一次模型
|
||||
rknn_model = init_rknn_model("cls_rk3568.rknn")
|
||||
|
||||
# 读取图像
|
||||
bgr_image = cv2.imread("12.jpg")
|
||||
rgb_image = cv2.cvtColor(bgr_image, cv2.COLOR_BGR2RGB)
|
||||
|
||||
# 使用已加载模型进行推理
|
||||
class_id, bool_value = yolov11_cls_inference_once(rknn_model, rgb_image)
|
||||
|
||||
if bool_value:
|
||||
print("夹具夹紧")
|
||||
else:
|
||||
print("夹具打开")
|
||||
```
|
||||
Reference in New Issue
Block a user