Challenge

Project 4

The steps involved in Lane detection are:

Capturing and detecting video files:

We will capture the video using the VideoCapture object and after capturing has been initialized every video frame is decoded.

Grayscale conversion of image:

The video frame is in RGB format, and RBG is converted to grayscale because processing into a single-channel image is faster than processing a three-channel colored image.

Reduce Noise:

Noise can create false edges, therefore before going further, it is imperative to perform image smoothening.

Canny Edge detection:

It computes the gradient in all directions of our blurred image and traces the edges with significant intensity changes.

REGION OF INTEREST:

This step takes into account only the region covered by road lanes. A mask is created here, which is of the same dimension as our road image. Furthermore, bitwise AND operation between each pixel of our canny image and this mask.

HOUGH LINE TRANSFORM:

The Hough Line Transform is a transform used to detect a straight line. Parameters are isolated gradient, rho, theta, and Minimum intersections needed per bin to be considered a line, placeholder array, minimum line length, and maximum line gap.

Optimizing and Displaying lines:

As the hough lines provide two lines. One line segment is the start line and the other one is the end line. Using these coordinates, we are going to calculate the slope and intercepts of each segment. After collecting line segments and classifying each line segment into either left line or right lines such as negative slope=right line and positive slope= left line. Extract the coordinates from line segments. Take the average of all line segments on both lists. After that, we created the triangle on the mask image with left, right, and straight in the form triangle. Then display the line we wanted to display such as lines and lane lines.

DISPLAYING THE LANE LINES:

Create a black image with the same dimension as our original image. Make sure that the lists with line points aren't empty. Loop through the lists, and extract the two pairs of x-y coordinates.

APPENDING THE LINES:

Appending the lines in the videos by the cv2.addweighted function

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.