Challenge

Project 4

Lane detection was performed on the given video using Hough transform.

Algorithm

1) The video is coverted to frames by using the cv2.VideoCapture() function and reading the video.

2) Each frame is iterated and lane detection is performed

3) The frame is converted from BGR to Gray Scale

4) The canny edge detection is very sensitive to noise, hence the image is smoothened using Gaussian filter

5) The edge detection is perform using Cannyedge detector

6) Along with the lanes many other edges are detected. To filter those we consider only those edges that are in pixel locations which are in white(>155) others are set to zero. This is done as the lanes are in white color in the video.

7) The Region of interest is then cropped using ROI_masking() function to make it easy for implementing Hough Transform

8) Hough Lines are detected by hough_transformation function using suitable threshold, minimum length and maximum gap.

cv2.HoughLinesP() is used to find the hough lines

9) In very few frames we see there are no visible lanes. In such situations we make using of the lines in the previous frame.

10) The left lane and right lane is then predicted using average_slope_intercept() by calcualting the average slopes and intercepts of left and right lines.

11) The line is then drawn on the image using draw_lane_lines()

12) The final image with lane highlighted is stored in an array

13) These images are then coverted back to video using cv2.VideoWriter function.

Code:

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.

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.