2025-09-26 13:32:34 +08:00
|
|
|
|
# vision/angle_detector.py
|
|
|
|
|
|
import sys
|
|
|
|
|
|
import os
|
2025-11-17 00:05:40 +08:00
|
|
|
|
from vision.obb_angle_model.obb_angle import detect_two_box_angle
|
2025-09-26 13:32:34 +08:00
|
|
|
|
|
|
|
|
|
|
# 添加项目根目录到Python路径
|
2025-11-17 00:05:40 +08:00
|
|
|
|
# sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
2025-09-26 13:32:34 +08:00
|
|
|
|
|
2025-11-17 00:05:40 +08:00
|
|
|
|
def get_current_door_angle(model,image=None, image_path=None):
|
2025-09-26 13:32:34 +08:00
|
|
|
|
"""
|
|
|
|
|
|
通过视觉系统获取当前出砼门角度
|
|
|
|
|
|
:param model: 模型实例
|
|
|
|
|
|
:param image: 图像数组(numpy array)
|
|
|
|
|
|
:param image_path: 图片路径
|
|
|
|
|
|
:return: 角度值(度)
|
|
|
|
|
|
"""
|
|
|
|
|
|
try:
|
|
|
|
|
|
# 调用实际的角度检测函数
|
2025-11-17 00:05:40 +08:00
|
|
|
|
angle_deg, _ = detect_two_box_angle(
|
|
|
|
|
|
model_path=model,
|
|
|
|
|
|
rgb_frame=image
|
|
|
|
|
|
# ,image_path=image_path
|
2025-09-26 13:32:34 +08:00
|
|
|
|
)
|
|
|
|
|
|
return angle_deg
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"角度检测失败: {e}")
|
|
|
|
|
|
return None
|