This commit is contained in:
琉璃月光
2025-10-22 17:52:29 +08:00
parent c134abf749
commit 1ec9bbab60
18 changed files with 532 additions and 6 deletions

View File

@ -26,25 +26,50 @@
pip install opencv-python numpy rknnlite
```
## 函数调用
## 函数调用1.0
您也可以直接调用 calculate_offset_from_image 函数,以便集成到其他项目中:
示例 1: 仅获取偏移量(不画图)
**
```bash
from calculate_offset import calculate_offset_from_image
result = calculate_offset_from_image("your_image_path.jpg", visualize=False)
if result['success']:
print(f"Offset: DeltaX={result['dx_mm']:+.2f} mm, DeltaY={result['dy_mm']:+.2f} mm")
else:
print("Error:", result['message'])
**
```
示例 2: 获取偏移量并保存可视化图
**
```bash
from calculate_offset import calculate_offset_from_image
result = calculate_offset_from_image("your_image_path.jpg", visualize=True)
**
```
该函数返回一个包含下列字段的字典:
## 函数调用2.0
示例 1: 仅获取偏移量(不画图)
```bash
from caculate_diff2.0 import calculate_offset_from_image
result = calculate_offset_from_image("11.jpg", visualize=False)
if result['success']:
print(f"Offset: DeltaX={result['dx_mm']:+.2f} mm, DeltaY={result['dy_mm']:+.2f} mm")
else:
print("Error:", result['message'])
```
示例 2: 获取偏移量并保存可视化图
```bash
from caculate_diff2.0 import calculate_offset_from_image
result = calculate_offset_from_image("11.jpg", visualize=True)
```
##该函数返回一个包含下列字段的字典1.0
success: 成功标志True/False
dx_mm: 水平偏移(毫米)
@ -52,3 +77,18 @@ result = calculate_offset_from_image("your_image_path.jpg", visualize=True)
cx: 中心点 x 坐标(像素)
cy: 中心点 y 坐标(像素)
message: 错误信息或成功提示
##该函数返回一个包含下列字段的字典2.0
success: 成功标志True/False
dx_mm: 水平偏移(毫米)
dy_mm: 垂直偏移(毫米)
cx: 中心点 x 坐标(像素)
cy: 中心点 y 坐标(像素)
message: 错误信息或成功提示
class_id: 检测类别 ID #这里是bag的id是0
obj_conf: 检测置信度 #这就是识别为料袋的置信度
bbox: 检测矩形框 [x_left, y_top, width, height]
message: 错误信息或成功提示