如何使用 Python 将边界框坐标转换为 Yolo 坐标?

问题描述

我需要转换坐标。我有这种格式 <left> <top> <width> <height> 我需要这种格式的 x_center y_center width height。我该怎么做?

解决方法

中心就在边界框的中间。因此,只需将边界框宽度或高度的一半添加到您的左上角坐标即可。宽高不变

x_center = left + width / 2
y_center = top + height / 2