Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import cv2
  2. import os
  3. import pandas as pd
  4. import numpy as np
  5.  
  6. import matplotlib.pyplot as plt
  7. %matplotlib inline
  8.  
  9. # Get current working directory
  10. cwd = os.getcwd()
  11. print(cwd)
  12.  
  13. # Read the csv file into a data frame
  14. driving_log_df = pd.read_csv('driving_log.csv')
  15. print(driving_log_df.shape)
  16.  
  17. X_data_set = np.empty([len(driving_log_df['Center'])*3, 32, 32, 3])
  18. Y_data_set = np.empty(len(driving_log_df['Center'])*3)
  19. print(X_data_set.shape)
  20. print(Y_data_set.shape)
  21.  
  22. # Path to images
  23. images_path = cwd + "/IMG"
  24. print(images_path)
  25.  
  26. # Index
  27. index = 0
  28.  
  29. for file in os.listdir(images_path):
  30. image = cv2.imread(os.path.join(images_path, file), cv2.IMREAD_COLOR)
  31. image = cv2.resize(image, (32, 32))
  32.  
  33. # OpenCV reads images in the BGR format, convert them into RGB
  34. image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
  35.  
  36. # Copy the image
  37. X_data_set[index] = np.copy(image_rgb)
  38.  
  39. # Display images
  40. if(index==0):
  41. figure1 = plt.figure()
  42. plt.imshow(image_rgb)
  43. figure2 = plt.figure()
  44. plt.imshow(X_data_set[0])
  45.  
  46. index = index + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement