In [1]:
import csv

In [3]:
with open("data/driving_log.csv", "r") as r:
    with open("data/driving_log_all.csv", "w") as w:
        reader = csv.reader(r)
        writer = csv.writer(w)
        
        # skip header
        next(reader)
        
        # Write all the center camera rows and add extra rows for each left/right camera
        # Note we add 0.25 (+/-) to the steering angles to compensate for left/right images!
        for row in reader:
            # write first row with center camera
            writer.writerow(row)
            
            current_angle = float(row[3])
            
            # write second row with left camera and adjusted steering angle
            row[0] = row[1].strip()
            row[3] = current_angle + 0.25
            writer.writerow(row)
            
            # write third row with right camera ad adjusted steering angle
            row[0] = row[2].strip()
            row[3] = current_angle - 0.25
            writer.writerow(row)
        
        # data is a list of tuples (img path, steering angle, etc.)
        #data = np.array([row for row in reader])

print("Data augmented and written to file data/driving_log_all.csv")


Data augmented and written to file data/driving_log_all.csv

In [ ]: