Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import os
- import pandas as pd
- import numpy as np
- import matplotlib.pyplot as plt
- %matplotlib inline
- # Get current working directory
- cwd = os.getcwd()
- print(cwd)
- # Read the csv file into a data frame
- driving_log_df = pd.read_csv('driving_log.csv')
- print(driving_log_df.shape)
- X_data_set = np.empty([len(driving_log_df['Center'])*3, 32, 32, 3])
- Y_data_set = np.empty(len(driving_log_df['Center'])*3)
- print(X_data_set.shape)
- print(Y_data_set.shape)
- # Path to images
- images_path = cwd + "/IMG"
- print(images_path)
- # Index
- index = 0
- for file in os.listdir(images_path):
- image = cv2.imread(os.path.join(images_path, file), cv2.IMREAD_COLOR)
- image = cv2.resize(image, (32, 32))
- # OpenCV reads images in the BGR format, convert them into RGB
- image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
- # Copy the image
- X_data_set[index] = np.copy(image_rgb)
- # Display images
- if(index==0):
- figure1 = plt.figure()
- plt.imshow(image_rgb)
- figure2 = plt.figure()
- plt.imshow(X_data_set[0])
- index = index + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement