Reader small image

You're reading from  Hands-On Vision and Behavior for Self-Driving Cars

Product typeBook
Published inOct 2020
PublisherPackt
ISBN-139781800203587
Edition1st Edition
Tools
Right arrow
Authors (2):
Luca Venturi
Luca Venturi
author image
Luca Venturi

Luca Venturi has extensive experience as a programmer with world-class companies, including Ferrari and Opera Software. He has also worked for some start-ups, including Activetainment (maker of the world's first smart bike), Futurehome (a provider of smart home solutions), and CompanyBook (whose offerings apply artificial intelligence to sales). He worked on the Data Platform team at Tapad (Telenor Group), making petabytes of data accessible to the rest of the company, and is now the lead engineer of Piano Software's analytical database.
Read more about Luca Venturi

Krishtof Korda
Krishtof Korda
author image
Krishtof Korda

Krishtof Korda grew up in a mountainside home over which the US Navy's Blue Angels flew during the Reno Air Races each year. A graduate from the University of Southern California and the USMC Officer Candidate School, he set the Marine Corps obstacle course record of 51 seconds. He took his love of aviation to the USAF, flying aboard the C-5M Super Galaxy as a flight test engineer for 5 years, and engineered installations of airborne experiments for the USAF Test Pilot School for 4 years. Later, he transitioned to designing sensor integrations for autonomous cars at Lyft Level 5. Now he works as an applications engineer for Ouster, integrating LIDAR sensors in the fields of robotics, AVs, drones, and mining, and loves racing Enduro mountain bikes.
Read more about Krishtof Korda

View More author details
Right arrow

Finding the lanes using histograms

How could we understand, more or less, where the lanes are? Visually, for a human, the answer is simple: the lane is a long line. But what about a computer?

If we talk about vertical lines, one way could be to count the pixels that are white, on a certain column. But if we check the image with a turn, that might not work. However, if we reduce our attention to the bottom part of the image, the lines are a bit more vertical:

Figure 3.25 – Lane with a turn, after the threshold, the bottom part

Figure 3.25 – Lane with a turn, after the threshold, the bottom part

We can now count the pixels by column:

partial_img = img[img.shape[0] // 2:, :]  # Select the bottom part
hist = np.sum(partial_img, axis=0)  # axis 0: columns direction

To save the histogram as a graph, in a file, we can use Matplotlib:

import matplotlib.pyplot as plt

plt.plot(hist)plt.savefig(filename)plt.clf()

We obtain the following result:

Figure 3.26 – Left: histogram of a straight lane, right: histogram of a lane with a turn

Figure 3.26...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Vision and Behavior for Self-Driving Cars
Published in: Oct 2020Publisher: PacktISBN-13: 9781800203587

Authors (2)

author image
Luca Venturi

Luca Venturi has extensive experience as a programmer with world-class companies, including Ferrari and Opera Software. He has also worked for some start-ups, including Activetainment (maker of the world's first smart bike), Futurehome (a provider of smart home solutions), and CompanyBook (whose offerings apply artificial intelligence to sales). He worked on the Data Platform team at Tapad (Telenor Group), making petabytes of data accessible to the rest of the company, and is now the lead engineer of Piano Software's analytical database.
Read more about Luca Venturi

author image
Krishtof Korda

Krishtof Korda grew up in a mountainside home over which the US Navy's Blue Angels flew during the Reno Air Races each year. A graduate from the University of Southern California and the USMC Officer Candidate School, he set the Marine Corps obstacle course record of 51 seconds. He took his love of aviation to the USAF, flying aboard the C-5M Super Galaxy as a flight test engineer for 5 years, and engineered installations of airborne experiments for the USAF Test Pilot School for 4 years. Later, he transitioned to designing sensor integrations for autonomous cars at Lyft Level 5. Now he works as an applications engineer for Ouster, integrating LIDAR sensors in the fields of robotics, AVs, drones, and mining, and loves racing Enduro mountain bikes.
Read more about Krishtof Korda