Guest User

Untitled

a guest
Dec 10th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import json
  2. import urllib.request
  3. import cv2
  4. import os
  5. os.system('mkdir Images')
  6.  
  7. f=open('Indian_Number_plates.json')
  8. i=0
  9. data=''
  10. for line in f:
  11.  
  12. line=json.loads(line)
  13. points=line['annotation'][0]['points']
  14. H=line['annotation'][0]['imageHeight']
  15. W=line['annotation'][0]['imageWidth']
  16. xmin=points[0]['x']
  17. ymin=points[0]['y']
  18. xmax=points[1]['x']
  19. ymax=points[1]['y']
  20. data+=str("%f,%f,%f,%f,%f,%f"%(H,W,xmin,ymin,xmax,ymax))+'\n'
  21. link=line['content']
  22. fname='Images/'+str(i)+'.jpg'
  23. urllib.request.urlretrieve(link,fname)
  24. i=i+1
  25. f.close()
  26. f=open('label.csv','w')
  27. f.write(data)
  28. f.close()
  29.  
  30.  
  31.  
  32.  
  33. print(data)
Add Comment
Please, Sign In to add comment