convert_all_rawls.py 1016 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import os
  2. import argparse
  3. import glob
  4. def main():
  5. parser = argparse.ArgumentParser(description="Convert rawls file into png")
  6. parser.add_argument('--folder', type=str, help='folder with all rawls files', required=True)
  7. parser.add_argument('--output', type=str, help='folder with all png files', required=True)
  8. args = parser.parse_args()
  9. p_folder = args.folder
  10. p_output = args.output
  11. images_path = glob.glob(f"{p_folder}/**/**/*.rawls")
  12. for img in sorted(images_path):
  13. output_path = img.replace('.rawls', '.png')
  14. output_path = output_path.replace(p_folder, p_output)
  15. output_folder, _ = os.path.split(output_path)
  16. if not os.path.exists(output_folder):
  17. os.makedirs(output_folder)
  18. if not os.path.exists(output_path):
  19. os.system(f'./build/main/rawls_convert --image {img} --outfile {output_path}')
  20. else:
  21. print(f'{output_path} already exists')
  22. if __name__ == "__main__":
  23. main()