How to covert json of segmentated annotations to orientated bounding box

42 Views Asked by At

how to convert json file consisting of segmentated annotations into orientated bounded box annotation, i got the coordinates int he format of (cx,cy,w,h,r) where cx is center-x,width,height,rotation. but bounded boxes have only four values (x,y,w,h) and how to rotate the boxes. its not rotating.

i tried and got the boxes to get tightly resized according to the object but not able to rotate the boxes according to the objects

height, width = data["images"][annotation["image_id"] - 1]["height"], data["images"[annotation["image_id"] - 1]["width"]
mask = [np.array(segmentation).reshape(-1, 2).astype(np.int32)]
(x, y), (h, w), rotation = cv2.minAreaRect(mask[0])

bbox_annotation = {
        "id": annotation["id"],
        "image_id": annotation["image_id"],
        "category_id": annotation["category_id"],
        "bbox": [x, y, w, h],
        "rotation": rotation,
        "iscrowd": 0,
        "area": w * h
        # Add other attributes as needed
    }
0

There are 0 best solutions below