Created
September 29, 2022 08:15
-
-
Save webtk/896cad1062caea540ef847a1af70aad3 to your computer and use it in GitHub Desktop.
Extraction polygon from annotation data of rendered.ai(synthetic dataset)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import ImageDraw as D | |
from PIL import Image | |
from PIL import ImagePath | |
import json | |
with open('syn_sample/annotations/0000000000-1-Image-ana.json','r') as f: | |
annotation = json.load(f) | |
i = Image.open("syn_sample/images/0000000000-1-Image.png") | |
draw = D.Draw(i) | |
objects = annotation['annotations'] | |
for obj in objects: | |
#bbox=obj['bbox'] | |
#draw.rectangle(bbox, outline="white") | |
parts = obj['segmentation'] | |
for part in parts: | |
draw.polygon(part) | |
i.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment