Last active
September 29, 2022 08:11
-
-
Save webtk/fdb5748e2c1deefa559368d6da0e3df8 to your computer and use it in GitHub Desktop.
Tried to extract bbox from 'Rendered.ai' 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: | |
x,y,w,h = obj['bbox'] | |
draw.rectangle(((x,y), (x+w, y+h)), outline="white") | |
i.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bbox format is [originX, originY, width, height]
So solution would be:
for obj in objects:
x,y,w,h = obj['bbox']
draw.rectangle(((x,y), (x+w, y+h)), outline="white")