Files
Feeding_control_system/vision/angle_detector.py
2025-09-26 13:32:34 +08:00

28 lines
799 B
Python
Raw Permalink 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.

# vision/angle_detector.py
import sys
import os
from vision.anger_caculate import predict_obb_best_angle
# 添加项目根目录到Python路径
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
def get_current_door_angle(model=None, image=None, image_path=None):
"""
通过视觉系统获取当前出砼门角度
:param model: 模型实例
:param image: 图像数组numpy array
:param image_path: 图片路径
:return: 角度值(度)
"""
try:
# 调用实际的角度检测函数
angle_deg, _ = predict_obb_best_angle(
model=model,
image=image,
image_path=image_path
)
return angle_deg
except Exception as e:
print(f"角度检测失败: {e}")
return None