Skip to content

Instantly share code, notes, and snippets.

@omar-faruk
Created December 11, 2018 03:37
Show Gist options
  • Select an option

  • Save omar-faruk/deff49133c77d4f44e1a099e1e05a85a to your computer and use it in GitHub Desktop.

Select an option

Save omar-faruk/deff49133c77d4f44e1a099e1e05a85a to your computer and use it in GitHub Desktop.
Indian Dataset downloader
import json
import urllib.request
import cv2
import os
os.system('mkdir Images')
f=open('Indian_Number_plates.json')
i=0
data=''
for line in f:
line=json.loads(line)
points=line['annotation'][0]['points']
H=line['annotation'][0]['imageHeight']
W=line['annotation'][0]['imageWidth']
xmin=points[0]['x']
ymin=points[0]['y']
xmax=points[1]['x']
ymax=points[1]['y']
data+=str("%f,%f,%f,%f,%f,%f"%(H,W,xmin,ymin,xmax,ymax))+'\n'
link=line['content']
fname='Images/'+str(i)+'.jpg'
urllib.request.urlretrieve(link,fname)
i=i+1
f.close()
f=open('label.csv','w')
f.write(data)
f.close()
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment