You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求协助:将[xmin, ymin, width, height]标注转换为YOLOv7格式

边界框格式转YOLOv7步骤及示例计算

YOLOv7的标注规则是每行对应一个目标,格式为:类别ID 归一化中心X 归一化中心Y 归一化宽度 归一化高度,所有坐标值需转换为相对于图像宽高的0-1区间浮点数。

转换公式

给定参数:

  • 图像尺寸:img_w(图像宽度)、img_h(图像高度)
  • 原标注格式:[xmin, ymin, bbox_w, bbox_h](xmin/ymin为框左上角坐标,bbox_w/bbox_h为框的宽高)

转换分两步:

  1. 计算边界框的中心坐标:
    • center_x = xmin + bbox_w / 2
    • center_y = ymin + bbox_h / 2
  2. 对所有值做归一化处理(除以对应图像维度):
    • norm_center_x = center_x / img_w
    • norm_center_y = center_y / img_h
    • norm_bbox_w = bbox_w / img_w
    • norm_bbox_h = bbox_h / img_h

示例计算

输入参数:

  • 图像尺寸:img_w=9477px,img_h=23354px
  • 原标注:[2009, 21947, 207, 251]

计算过程:

  1. 中心坐标计算:
    • center_x = 2009 + 207/2 = 2112.5
    • center_y = 21947 + 251/2 = 22072.5
  2. 归一化计算:
    • norm_center_x = 2112.5 / 9477 ≈ 0.222908
    • norm_center_y = 22072.5 / 23354 ≈ 0.945127
    • norm_bbox_w = 207 / 9477 ≈ 0.021842
    • norm_bbox_h = 251 / 23354 ≈ 0.010748

最终YOLOv7格式标注(假设类别ID为0):

0 0.222908 0.945127 0.021842 0.010748

内容的提问来源于stack exchange,提问作者NoSleepDeveloper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 23:35:27