No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

get_val_data.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. import os
  3. import params
  4. import cv2
  5. import numpy as np
  6. # make the val data
  7. def val_data():
  8. val_x = []
  9. val_y = []
  10. file_list = os.listdir('/raw_data/eval_data')
  11. for file in file_list:
  12. if file.endswith('.npy'):
  13. file_location = "/raw_data/eval_data/" + file
  14. loaded_data = np.load(file_location)
  15. for data in loaded_data:
  16. tmp = cv2.flip(data[0],0)
  17. tmp = cv2.flip(tmp,1)
  18. if params.img_channels != 3:
  19. tmp = cv2.cvtColor(tmp, cv2.COLOR_BGR2GRAY)
  20. data[0] = (tmp[70:-5,::]).reshape(params.img_height, params.img_width, params.img_channels)
  21. # change the can data (HEX) to numerical data
  22. tmp = data[1]
  23. hex_data = tmp[-23:-21] + tmp[-20:-18]
  24. hex_decimal = tmp[-3:-1]
  25. int_data = int(hex_data, 16)
  26. int_decimal = int(hex_decimal, 16) / 256
  27. # if the steering wheel angle in in right to the center
  28. if(int_data > 550):
  29. int_data = int_data - 4096
  30. int_decimal = 1 - int_decimal
  31. final_data = int_data - int_decimal
  32. else:
  33. # put the int and the decimal together
  34. final_data = int_data + int_decimal
  35. data[1] = final_data
  36. loaded_data = loaded_data[50:]
  37. tmp_x = np.array([i[0] for i in loaded_data]).reshape([-1, params.img_height, params.img_width, params.img_channels])
  38. tmp_y = np.array([i[1] for i in loaded_data]).reshape([-1,1])
  39. val_x.extend(tmp_x)
  40. val_y.extend(tmp_y)
  41. return val_x, val_y
  42. # finish making val data