更改边界框标签格式

问题描述

我一直在寻找一种在线服务,该服务允许我用边界框注释图像,labelbox,但是边界框标签格式不同于我需要的格式yolo。

这是格式:"bBox": { "top": 186,"left": 192,"height": 300,"width": 519 }

我需要的格式是x_center y_center width height,而且值也必须介于0和1之间

解决方法

bbox = {"top": 186,"left": 192,"height": 300,"width": 519}

y1 = bbox["top"]
x1 = bbox["left"]
height = bbox["height"]
width = bbox["width"]

x2 = x1+width
y2 = y1+height

x_center = round((x1+x2)/2)
y_center = round((y1+y2)/2)

bbox_list = [x_center,y_center,width,height]