此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 函数
  • corners_to_rotated_bbox
  • normalize_bboxes
  • rotated_bbox_to_corners
  • top_left_wh_to_xywh
  • xywh_to_xyxy
  • xyxy_to_xywh
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

bbox_format_converters

最后更新
Python API: depthai_nodes.node.parsers.utils.bbox_format_converters

函数

corners_to_rotated_bbox

Python
1def corners_to_rotated_bbox(corners: np.ndarray) -> np.ndarray:
将边界框的角点转换为旋转边界框。参数
  • corners (np.ndarray): 边界框的角点。角点应按左上、右上、右下、左下的顺序排列。
返回
  • np.ndarray: 定义为 [x_center, y_center, width, height, angle] 的旋转边界框。

normalize_bboxes

Python
1def normalize_bboxes(bboxes: np.ndarray, height: int, width: int) -> np.ndarray:
将边界框坐标归一化到 (0, 1)。参数
  • bboxes (np.ndarray): 包含边界框的形状为 (N, 4) 的 numpy 数组。
  • height (int): 图像的高度。
  • width (int): 图像的宽度。
返回
  • np.ndarray: 包含归一化边界框的形状为 (N, 4) 的 numpy 数组。

rotated_bbox_to_corners

Python
1def rotated_bbox_to_corners(cx: float, cy: float, w: float, h: float, rotation: float) -> np.ndarray:
将旋转边界框转换为边界框的角点。参数
  • cx (float): 边界框中心的 x 坐标。
  • cy (float): 边界框中心的 y 坐标。
  • w (float): 边界框的宽度。
  • h (float): 边界框的高度。
  • rotation (float): 边界框的角度,以度为单位。
返回
  • np.ndarray: 边界框的角点。

top_left_wh_to_xywh

Python
1def top_left_wh_to_xywh(bboxes: np.ndarray) -> np.ndarray:
将边界框从 [top_left_x, top_left_y, width, height] 转换为 [x_center, y_center, width, height]。参数
  • bboxes (np.ndarray): 要转换的边界框。
返回
  • np.ndarray: 转换后的边界框。

xywh_to_xyxy

Python
1def xywh_to_xyxy(bboxes: np.ndarray) -> np.ndarray:
将边界框坐标从 (x_center, y_center, width, height) 转换为 (x_min, y_min, x_max, y_max)。参数
  • bboxes (np.ndarray): 包含 (x, y, width, height) 格式边界框的形状为 (N, 4) 的 numpy 数组。
返回
  • np.ndarray: 包含 (x_min, y_min, x_max, y_max) 格式边界框的形状为 (N, 4) 的 numpy 数组。

xyxy_to_xywh

Python
1def xyxy_to_xywh(bboxes: np.ndarray) -> np.ndarray:
将边界框从 [x_min, y_min, x_max, y_max] 转换为 [x_center, y_center, width, height]。参数
  • bboxes (np.ndarray): 要转换的边界框。
返回
  • np.ndarray: 转换后的边界框。