Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Last active June 6, 2017 13:07
Show Gist options
  • Select an option

  • Save hackintoshrao/72dc41903fa04cc5f5be60484d72dc9e to your computer and use it in GitHub Desktop.

Select an option

Save hackintoshrao/72dc41903fa04cc5f5be60484d72dc9e to your computer and use it in GitHub Desktop.
Reading the image and the data
import csv
import cv2
import numpy as np
# Data read from csv. CSV contains the image path and steerig angles recorded at various points of gameplay.
lines = []
csvPath = "/Users/hackintoshrao/Documents/code/self-drive/driving_log.csv"
with open(csvPath) as csvData:
# read from csv
reader = csv.reader(csvData)
for line in reader:
lines.append(line)
# images from gameplay are read from disk and queued here.
cameraImages = []
# corresponding steering measurements are queued up here.
steeringMeasurements = []
for line in lines:
imgPath = line[0]
img = cv2.imread(imgPath)
cameraImages.append(img)
measurement = float(line[3])
steeringMeasurements.append(measurement)
# convert the images and measurements to numpy array.
xTrain = np.array(cameraImages)
yTrain = np.array(steeringMeasurements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment