def METHOD_NAME(ROOT, TRACK, SPLIT):
    coco_data = {
        "images": [],
        "annotations": [],
        "categories": [{"id": 1, "name": "table"}, ],
    }
    DATA_DIR = f"{ROOT}/{TRACK}/{SPLIT}"
    prefix = "cTDaR_t0" if TRACK == "trackA_archival" else "cTDaR_t1"
    print(TRACK, SPLIT, prefix)
    table_count = 0
    for file in sorted(os.listdir(DATA_DIR)):
        if file.startswith(prefix) and file.endswith(".jpg"):
            img = Image.open(os.path.join(DATA_DIR, file))
            coco_data["images"].append(
                {
                    "file_name": file,
                    "height": img.height,
                    "width": img.width,
                    "id": int(file[7:-4]),
                }
            )
        elif file.startswith(prefix) and file.endswith(".xml"):
            # print(file)
            tree = ET.parse(os.path.join(DATA_DIR, file))
            root = tree.getroot()
            assert len(root.findall("./table/Coords")) > 0
            for table_id in range(len(root.findall("./table/Coords"))):
                four_points = root.findall("./table/Coords")[table_id].attrib["points"]
                four_points = list(map(lambda x: x.split(","), four_points.split()))
                four_points = [[int(j) for j in i] for i in four_points]
                segmentation = [j for i in four_points for j in i]
                bbox = [
                    four_points[0][0],
                    four_points[0][1],
                    four_points[2][0] - four_points[0][0],
                    four_points[2][1] - four_points[0][1],
                ]
                coco_data["annotations"].append(
                    {
                        "segmentation": [segmentation],
                        "area": bbox[2] * bbox[3],
                        "iscrowd": 0,
                        "image_id": int(file[7:-4]),
                        "bbox": bbox,
                        "category_id": 1,
                        "id": table_count,
                    }
                )
                table_count += 1
    with open(f"{ROOT}/{TRACK}/{SPLIT}.json", "w") as f:
        json.dump(coco_data, f)