如何将YOLO格式标注转换成Python中的x1,y1,x2,y2坐标?

How to convert YOLO format annotations to x1, y1, x2, y2 coordinates in Python?

我想知道如何将YOLO格式的标注(如center_X, center_y, width, height = 0.069824, 0.123535, 0.104492, 0.120117)转换为x1, y1, x2 , y2 坐标?

鉴于图像的左上角是[0,0]:对于左上角你必须做[x,y] = [center_X, center_Y] - 1/2 * [width, height] 。对于右下角 [x,y] = [center_X, center_Y] + 1/2 * [width, height] .

如果我没记错的话:

x1 = (center_X-width/2)*image_width
x2 = (center_X+width/2)*image_width
y1 = (center_y-height/2)*image_height
y2 = (center_y+height/2)*image_height