Bez popisu

createSeedFiles.py 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Thu Aug 31 10:29:21 2017
  5. @author: datascience9
  6. """
  7. import os
  8. import glob
  9. # get working directory
  10. loc = os.path.abspath('')
  11. # import dataset containing cars and non-cars
  12. cars = glob.glob("/Users/datascience9/Veh Detection/Udacity Data/vehicles/*/*.png")
  13. non_cars = glob.glob("/Users/datascience9/Veh Detection/Udacity Data/non-vehicles/*/*.png")
  14. def create_pos_n_neg():
  15. for file_type in ['non_cars']:
  16. for img in os.listdir('non-vehicles/GTI/'):
  17. if file_type == 'non_cars':
  18. line = 'non-vehicles/GTI/'+img+'\n'
  19. with open('bg.txt','a') as f:
  20. f.write(line)
  21. for img in os.listdir('non-vehicles/Extras/'):
  22. if file_type == 'non_cars':
  23. line = 'non-vehicles/Extras/'+img+'\n'
  24. with open('bg.txt','a') as f:
  25. f.write(line)
  26. for file_type in ['cars']:
  27. for img in os.listdir('vehicles/GTI_Far/'):
  28. if file_type == 'cars':
  29. line = 'vehicles/GTI_Far/'+img+' 1 0 0 64 64\n'
  30. with open('info.lst','a') as f:
  31. f.write(line)
  32. for img in os.listdir('vehicles/GTI_Left/'):
  33. if file_type == 'cars':
  34. line = 'vehicles/GTI_Left/'+img+' 1 0 0 64 64\n'
  35. with open('info.lst','a') as f:
  36. f.write(line)
  37. for img in os.listdir('vehicles/GTI_MiddleClose/'):
  38. if file_type == 'cars':
  39. line = 'vehicles/GTI_MiddleClose/'+img+' 1 0 0 64 64\n'
  40. with open('info.lst','a') as f:
  41. f.write(line)
  42. for img in os.listdir('vehicles/GTI_Right/'):
  43. if file_type == 'cars':
  44. line = 'vehicles/GTI_Right/'+img+' 1 0 0 64 64\n'
  45. with open('info.lst','a') as f:
  46. f.write(line)
  47. for img in os.listdir('vehicles/KITTI_extracted/'):
  48. if file_type == 'cars':
  49. line = 'vehicles/KITTI_extracted/'+img+' 1 0 0 64 64\n'
  50. with open('info.lst','a') as f:
  51. f.write(line)
  52. create_pos_n_neg()