Shortcuts

box_convert

torchvision.ops.box_convert(boxes: Tensor, in_fmt: str, out_fmt: str) Tensor[source]

torch.Tensor的框从给定的in_fmt转换为out_fmt

注意

为了在不同的格式之间转换torch.TensorBoundingBoxes对象, 考虑使用convert_bounding_box_format()代替。 或者查看相应的转换ConvertBoundingBoxFormat()

支持的 in_fmtout_fmt 字符串有:

'xyxy': 框通过角点表示,x1, y1 是左上角,x2, y2 是右下角。 这是 torchvision 工具期望的格式。

'xywh': 框通过角点、宽度和高度表示,x1, y2 是左上角,w, h 是宽度和高度。

'cxcywh': 框通过中心、宽度和高度表示,cx, cy 是框的中心,w, h 是宽度和高度。

Parameters:
  • boxes (Tensor[N, 4]) – 将被转换的框。

  • in_fmt (str) – 给定框的输入格式。支持的格式有 [‘xyxy’, ‘xywh’, ‘cxcywh’]。

  • out_fmt (str) – 给定框的输出格式。支持的格式有 [‘xyxy’, ‘xywh’, ‘cxcywh’]

Returns:

将盒子转换为指定格式。

Return type:

张量[N, 4]