Json formats exported using Object Detection with Bounding Boxes include x,y,width,height,rotation. How do you of the remaining three points?

Json formats exported using Object Detection with Bounding Boxes include x,y,width,height,rotation. How do you calculate the coordinates of the remaining three points?
The document explains that the exported x,y is before the rotation, but the actual use of the output is found to be the rotation of x,y。

I want to calculate the coordinates of the other three points, here’s my code:
def convert_bbox_to_points(x, y, width, height, rotation, original_width, original_height):
# 计算矩形的中心点
center_x = x + width / 2
center_y = y + height / 2

# 计算四个顶点相对于中心点的坐标
points = []
for dx, dy in [(-width / 2, -height / 2), (width / 2, -height / 2), (width / 2, height / 2), (-width / 2, height / 2)]:
    # 旋转坐标
    cos_theta = math.cos(math.radians(rotation))
    sin_theta = math.sin(math.radians(rotation))
    new_dx = dx * cos_theta - dy * sin_theta
    new_dy = dx * sin_theta + dy * cos_theta
    
    # 转换为绝对坐标
    abs_x = center_x + new_dx
    abs_y = center_y + new_dy
    
    # 转换为图像的绝对坐标
    abs_x = abs_x * original_width / 100
    abs_y = abs_y * original_height / 100
    
    points.append([abs_x, abs_y])

# 确保点的顺序为左上、右上、右下、左下
points = [points[0], points[1], points[2], points[3]]

return points

Because x,y are the values after rotation, there is an error if the rotation angle is not 0

this is example

Check this function for yolo obb, looks like you need the same:

def convert_annotation_to_yolo_obb(label, normalize=True):
    """
    Convert LS annotation to Yolo OBB format.

    Args:
        label (dict): Dictionary containing annotation information including:
            - original_width (int): Original width of the image.
            - original_height (int): Original height of the image.
            - x (float): X-coordinate of the top-left corner of the object in percentage of the original width.
            - y (float): Y-coordinate of the top-left corner of the object in percentage of the original height.
            - width (float): Width of the object in percentage of the original width.
            - height (float): Height of the object in percentage of the original height.
            - rotation (float, optional): Rotation angle of the object in degrees (default is 0).
        normalize (bool, optional): Whether to normalize the coordinates to the range [0, 1] (default is True).

    Returns:
        list of tuple or None: List of tuples containing the coordinates of the object in Yolo OBB format.
            Each tuple represents a corner of the bounding box in the order:
            (top-left, top-right, bottom-right, bottom-left).
    """

    if not (
        "original_width" in label
        and "original_height" in label
        and "x" in label
        and "y" in label
        and "width" in label
        and "height" in label
        and "rotation" in label
    ):
        return None

    org_width, org_height = label["original_width"], label["original_height"]
    x = label["x"] / 100 * org_width
    y = label["y"] / 100 * org_height
    w = label["width"] / 100 * org_width
    h = label["height"] / 100 * org_height

    rotation = math.radians(label.get("rotation", 0))
    cos, sin = math.cos(rotation), math.sin(rotation)

    coords = [
        (x, y),
        (x + w * cos, y + w * sin),
        (x + w * cos - h * sin, y + w * sin + h * cos),
        (x - h * sin, y + h * cos),
    ]

    # Normalize coordinates
    if normalize:
        return [(coord[0] / org_width, coord[1] / org_height) for coord in coords]
    else:
        return coords

Understood, thank you very much