Skip to content

Instantly share code, notes, and snippets.

@webtk
Last active September 29, 2022 08:11
Show Gist options
  • Save webtk/fdb5748e2c1deefa559368d6da0e3df8 to your computer and use it in GitHub Desktop.
Save webtk/fdb5748e2c1deefa559368d6da0e3df8 to your computer and use it in GitHub Desktop.
Tried to extract bbox from 'Rendered.ai' Dataset.
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:
x,y,w,h = obj['bbox']
draw.rectangle(((x,y), (x+w, y+h)), outline="white")
i.show()
@webtk
Copy link
Author

webtk commented Sep 29, 2022

@3dhedges Thanks. It works!
image
Is it possible to get Rotated BBox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment