0% found this document useful (0 votes)
148 views18 pages

Lane Line Detection Using Hough Transform (Pipeling For Videos)

This document is a project report submitted by Sourav Dey and Isha for their Parallel and Distributed Computing course. The project aims to develop a lane line detection system using Hough transform that can process video streams in a pipeline. The methodology section describes the pipeline as: 1) converting images to grayscale, 2) applying Gaussian blur, 3) Canny edge detection, 4) defining a region of interest, 5) Hough transform line detection, and 6) averaging and extrapolating the left and right lane lines. The system works to detect lane lines in individual images and then apply the results to video streams to warn drivers if they move out of their lane.

Uploaded by

Sourav Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views18 pages

Lane Line Detection Using Hough Transform (Pipeling For Videos)

This document is a project report submitted by Sourav Dey and Isha for their Parallel and Distributed Computing course. The project aims to develop a lane line detection system using Hough transform that can process video streams in a pipeline. The methodology section describes the pipeline as: 1) converting images to grayscale, 2) applying Gaussian blur, 3) Canny edge detection, 4) defining a region of interest, 5) Hough transform line detection, and 6) averaging and extrapolating the left and right lane lines. The system works to detect lane lines in individual images and then apply the results to video streams to warn drivers if they move out of their lane.

Uploaded by

Sourav Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 18

Lane Line Detection Using Hough

Transform (Pipeling for videos)

A PROJECT REPORT

Submitted by

SOURAV DEY-17BCE0019
ISHA -17BCE0282

Parallel and Distributed Computing


CSE4001

Slot – L55+L56

Faculty:

Prof. Umadevi K.S.

SCHOOL OF COMPUTER SCIENCE AND ENGINEERING


November 2019
TABLE OF CONTENTS

ABSTRACT

Chapter 1: INTRODUCTION
Chapter 2: LITERATURE REVIEW

Chapter 3: METHODOLOGY

Chapter 4: RESULTS AND DISCUSSION

Chapter 5: CONCLUSION AND FUTURE WORK

APPENDICES

REFERENCES
ABSTRACT

According to The Times of India, about 150,000 people were killed in road accidents in the
last year. Of the many other reasons, lane changing is one of the most common cause of
accidents. Experts say that these accidents mostly occur due to distractions often due to the
idea that one can multitask. Another risk factor is driving slowly in the right lane,
compelling the other drivers to drive faster to switch lanes. When we drive, we use our eyes
to decide where to go. The lines on the road that show us where the lanes are acting as our
constant reference for where to steer the vehicle. Lane detection can be considered a
potential solution to the accidents. It is a system devised to warn the driver when the vehicle
begins to move out of its current lane. The system detects the lines of the images from the
input image (or video) and selects the lane marker of the road surface from that. Hough
transform is used to extricate the lines off an image. Such a system can warn the driver when
has the tendency to move out from the lane, without being aware of it.
CHAPTER 1: INTRODUCTION

To accurately extract road information in autonomous navigation of unmanned vehicles


and vehicle intelligent early warning system s of great importance. All kinds of algo-
rithms have been proposed, in recent decades, for the realisation of automatic identifica-
tion of structural and unstructured roads. Nowadays, demands on vehicles are increasing
because of the rapid population growth. This leads to the major causes of higher road ac-
cidents Nearly 3,500 people die on the road every day. It is found that the lane changing
is the cause of most accidents. This system can serve as a tool to prevent such accidents.
The system uses an image processing mechanism to detect the lines on a image, selects
the current lane markers and warns the driver if the vehicle leaves the current lane and
this continues for the next frame. These kinds of studies are the basis of lane departure
warning and lane keeping assistance systems. An important feature for reducing the acci-
dent risk and increasing driving safety is accurate and automatic detection. This method
has the advantages of simplicity, practicability, and adaptability to the characteristics of
the structural environment of expressway. It is also characterised by faster image process-
ing speed and better real-time performance. The lane line exclusion and detection can be
implemented based on the relationship of lane lines, vanishing points and intercepts in the
Hough transform space. When the algorithm is enhanced, the detecting efficiency locates
the lane lines accurately making the process simple. According to the pixel point accumu-
lation principle, the Hough transform extracts straight lines therefore, the fitting effect of
a straight line is better.
CHAPTER 2: LITERATURE REVIEW

Reference 1 mentions the performance hough transform on road lanes like this project
has been implemented. The paper also compares the Randomised Hough Transform
(RHT) and Standardised Hough Transform. The RHT computation consists of selecting 2
random pixels from edge image and calculating the parameter from the line of the point
connection. The RHT algorithm lies in the fact that each point in ρ-θ plane can be
expressed with 2 points or 1 line from the original binary edge image. On the Other hand
the SHT, uses finding the local maxima which represent line segments of the image and
extracting the line segments from the maxima positions. Computational complexity and
huge storage memory consumption are it’s disadvantages. This paper thoroughly de-
scribes these two with respect to their thresholds, including the various images it uses to
work. Hence the usage of it because it is very similar to that of this project.
Reference 2 talks about ways to simplify the lane line detection algorithm based on
Hough transform, proposing an algorithm that directly identifying lane line in Hough
space. The image is conducted with Hough transform, and the points conforming to the
parallel characteristics, length and angle characteristics, and intercept characteristics of
lane line are selected in Hough space. The points directly converted into the lane line
equations. Also, the lane lines are conducted with fusion and property identification. The
experimental results showed that the lane can be better identified on expressways and
structured roads. In comparison to a tradition algorithm, the identification is effectively
improved.
Reference 3 Gives the methodology of how the Transformation is applied and how the
code works. It provides the knowledge to understand the code implied and used. explain-
ing following techniques: Colour Selection, Canny Edge Detection, Region of Interest
Selection and Hough Transform Line Detection in detail.
CHAPTER 3: METHODOLOGY

The coloured image taken as input is first converted into a grayscale image. This helps to
reduce work as otherwise work would have to be done on the RGB scale. Then Gaussian
Blur is applied to the image. This is done to reduce image noise. Then the Canny Edge
Detection algorithm is applied on the smoothened image. Then a mask is applied to the
image from the Edge to filter the region of interest. This is done to remove parts of the
image where it is not expected to have roads.
Then the hough lines algorithm is applied to the masked edge image. This gives the line
segments where the edges are near the lane lines. Once the lines are obtained, the slope
of the line gives the left and right edge. A negative slope defines the left line and a
positive slope defines the right lane. Then an average of all the left line segments is taken
and ad extrapolated left line is drawn. The same method is used to get an extrapolated
right line. This gives the output of the lane’s end lines and thus alarming the driver when
the vehicle moves out of the lane.

!
Figure 1: System Overview
Python and OpenCV are used to detect lane lines on the road. We will develop a
process-ing pipeline that works on a series of individual images, and will apply the
result to a video stream.
Pipeline architecture

1. Load test images.


2. Apply Color Selection
3. Apply Canny edge detection.

The Canny edge detector was developed by John F. Canny in 1986.


We want to detect edges in order to find straight lines especially lane lines. For this,
• Convert images into gray scale - The images should be converted into gray scaled ones
in order to detect shapes (edges) in the images. This is because the Canny edge
detection measures the magnitude of pixel intensity changes or gradients (more on this
later).
• Smooth out rough lines - When there is an edge (i.e. a line), the pixel intensity changes
rapidly (i.e. from 0 to 255) which we want to detect. But before doing so, we should make
the edges smoother. As you can see, the above images have many rough edges which
causes many noisy edges to be detected. This is also called Gaussian Smoothing.
• Edge Detection - Canny edge detection which make use of the fact that edges has high
gradients (how sharply image changes — for example, dark to white).
4. Determine the region of interest.
When finding lane lines, we don’t need to check the sky and the hills.
5. Apply Hough transform.
6. Average and extrapolating the lane lines.
There are multiple lines detected for a lane line. Come up with an averaged line for
that. Some lane lines are only partially recognised. Extrapolate the line to cover full
lane line length.Take two lane lines: one for the left and the other for the right. The left
lane should have a positive slope, and the right lane should have a negative slope.
Therefore, collect only positive slope lines and negative slope lines separately and take
averages.
7. Apply on video streams.
Working Structure(PIPELINE)

We are first converting the color image (or a frame from a video) to a grayscale image.
This enables us to work on a single channel of the image, instead of working on all 3
channels (BGR). So this is computationally less intensive

Then we are applying Gaussian Blur to the image. I also tried Bilateral Filtering, since
this filtering preserves edges better, compared to Gaussian Filter. However, we did
not see a big advantage in this project, so we kept the Gaussian Filtering in my code
to be consistent with given specifications.

Then we applied Canny Edge detection on this smoothed image.

To make this process more efficient, we used a small GUI tool.

On this Edge image, we filtered region of interest by applying a mask. Since we are
primarily interested in edges in the region where we expect our road to be, we
removed the edges in other areas of the image.

Then we applied Hough Lines algorithm on this masked edge image. This gives us line
segments where we have edges near the lane lines.

Once we get the lane line segments, we extrapolated the left lane line and right lane
line, based on the angle.

Since we are using Polar coordinates in Hough Transform, our left line will have
negative slope and the right line will have positive slope. Based on this, we classify
each line segment to be either a left line segment or a right line segment. Then we
take average of all left line segments and draw an extrapolated left line. We apply
same method for extrapolating the right line segment as well. To make the
extrapolated lines more stable and less wobbly, we applied weighted sum of previous
slope and current slope of each line. This allows smooth transitioning of the slope, so
the outcome looks more stable.
CHAPTER 4: RESULT AND DISCUSSION

This is pipelined in the video.

!
CHAPTER 5: CONCLUSION AND FUTURE WORK

There have been several lane detection algorithms that have come up to solve the
problem. But there are few disadvantages also, like:
The disadvantage of robust lane detection in shadows and low illumination conditions is
that it cannot detect any high dynamic range portion of the image.
Most of the other detection methods cannot verify the colors of lane markers.
But, through Hough Transform, this can be done using lane hypothesis verification.
Therefore, we conclude that Hough transform is a more suitable solution for various
lane detection problems.
In future, this transform could be modified for using it on curvatures and circular roads as
well.
APPENDICES
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
get_ipython().run_line_magic('matplotlib', 'inline')

image = mpimg.imread('test_images/solidWhiteRight.jpg')

print('This image is:', type(image), 'with dimesions:', image.shape)


plt.imshow(image)
import math

def grayscale(img):

return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)

def canny(img, low_threshold, high_threshold):

return cv2.Canny(img, low_threshold, high_threshold)

def gaussian_blur(img, kernel_size):

return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)

def median_blur(img, kernel_size):

return cv2.medianBlur(img, kernel_size)

def region_of_interest(img, vertices):

mask = np.zeros_like(img)

#defining a 3 channel or 1 channel color to fill the mask with depending on


the input image
if len(img.shape) > 2:
channel_count = img.shape[2] # i.e. 3 or 4 depending on your image
ignore_mask_color = (255,) * channel_count
else:
ignore_mask_color = 255

#filling pixels inside the polygon defined by "vertices" with the fill col-
or
cv2.fillPoly(mask, vertices, ignore_mask_color)

#returning the image only where mask pixels are nonzero


masked_image = cv2.bitwise_and(img, mask) return
masked_image
def draw_lines(img, lines, color=[255, 0, 0], thickness=2):

for line in lines:


for x1,y1,x2,y2 in line:
cv2.line(img, (x1, y1), (x2, y2), color, thickness)

def get_y_intercept(lane_lines, slopes):


slopes = slopes[~np.isnan(slopes)]
slopes = slopes[~np.isinf(slopes)]
avg_slope = slopes.mean()
lane_lines = lane_lines.reshape((lane_lines.shape[0]*2,
lane_lines.shape[1]//2))
x_min, y_min = np.mean(lane_lines, axis=0)
return y_min - (x_min*avg_slope), avg_slope

def get_x_intercepts(y_1, y_2, slope, b):


if not (~np.isnan(slope) and ~np.isnan(b)):
x_1 = x_2 = 0.0
else:
x_1 = (y_1 - b)/slope
x_2 = (y_2 - b)/slope
return x_1, x_2

prev_left_x1 = 0
prev_left_x2 = 0
prev_right_x1 = 0
prev_right_x2 = 0
prev_left_avg_m = 0
prev_right_avg_m = 0
pev_left_avg_m = -1
prev_right_avg_m = 1
prev_left_b = 0
prev_right_b = 0
prev_left_line = 0
prev_right_line = 0

def draw_lines_extrapolated(img, lines, color=[255, 0, 0], thickness=10):


imgshape = img.shape
lines = lines.reshape((lines.shape[0], lines.shape[2]))
y_min = lines.reshape((lines.shape[0]*2, lines.shape[1]//2))[:,1].min()

# slope= ( y2 - y1 )/( x2 - x1 )
slopes = (lines[:,3] - lines[:,1])/(lines[:,2] - lines[:,0])
slopes = slopes[~np.isinf(slopes)]
slopes = slopes[~np.isnan(slopes)]
left_lines = lines[slopes < -0.5] # Left lines should have negative
slope, thershold=-0.5
right_lines= lines[slopes > 0.5] # Right lines should have positive
slope, threshold=+0.5
left_slopes = slopes[slopes < -0.5]
right_slopes= slopes[slopes > 0.5]

global prev_left_avg_m
global prev_right_avg_m
global prev_left_b
global prev_right_b

left_b, left_avg_m = get_y_intercept(left_lines, left_slopes)


right_b, right_avg_m = get_y_intercept(right_lines, right_slopes)

keep_prev_left = False
keep_prev_right = False

if left_avg_m < -0.83 or left_avg_m > -0.36:


left_avg_m = prev_left_avg_m
left_b = prev_left_b
keep_prev_left = True
if right_avg_m > 0.83 or right_avg_m < 0.36:
right_avg_m = prev_right_avg_m
right_b = prev_right_b
keep_prev_right = True

prev_left_avg_m = left_avg_m
prev_right_avg_m = right_avg_m
prev_left_b = left_b
prev_right_b = right_b

# using y_min, avg_slope and y_intercept find x1 and x2


left_x1, left_x2 = get_x_intercepts(y_1=y_min, y_2=imgshape[0],
slope=left-_avg_m, b=left_b)
right_x1, right_x2 = get_x_intercepts(y_1=y_min, y_2=imgshape[0],
slope=right_avg_m, b=right_b)
## Apply first order filter ##
global prev_left_x1
global prev_left_x2
global prev_right_x1
global prev_right_x2

if prev_left_x1 != 0 or prev_left_x2 != 0 or prev_right_x1 != 0 or pre-


v_right_x2 !=0:
alpha = 0.2
left_x1_new = math.floor((alpha)*left_x1 + (1-alpha)*prev_left_x1)
left_x2_new = math.floor((alpha)*left_x2 + (1-alpha)*prev_left_x2)
right_x1_new = math.floor((alpha)*right_x1 + (1-alpha)*prev_right_x1)
right_x2_new = math.floor((alpha)*right_x2 + (1-alpha)*prev_right_x2)
prev_left_x1 = left_x1_new
prev_left_x2 = left_x2_new
prev_right_x1 = right_x1_new
prev_right_x2 = right_x2_new
else:
left_x1_new = left_x1
left_x2_new = left_x2
right_x1_new = right_x1
right_x2_new = right_x2
prev_left_x1 = left_x1_new
prev_left_x2 = left_x2_new
prev_right_x1 = right_x1_new
prev_right_x2 = right_x2_new

left_line = np.array([left_x1_new, y_min, left_x2_new, imgshape[0]],


dtype=np.int32)
right_line = np.array([right_x1_new, y_min, right_x2_new, imgshape[0]],
dtype=np.int32)
if keep_prev_left:
left_line = prev_left_line
left_x1_new = prev_left_x1
left_x2_new = prev_left_x2
if keep_prev_right:
right_line = prev_right_line
right_x1_new = prev_right_x1
right_x2_new = prev_right_x2

cv2.line(img, (int(left_x1_new), int(y_min)),


(int(left_x2_new), imgshape[0]), color, thickness)
cv2.line(img, (int(right_x1_new), int(y_min)), (int(right_x2_new),
imgshape[0]), color, thickness)
def hough_lines(img, rho, theta, threshold, min_line_len, max_line_gap,
extrap-olate=False, curvy=False):
lines = cv2.HoughLinesP(img, rho, theta, threshold, np.array([]),
minLine-Length=min_line_len, maxLineGap=max_line_gap)
line_img = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8)
if not extrapolate and not curvy:
draw_lines(line_img, lines)
elif extrapolate:
draw_lines_extrapolated(line_img, lines)
else:
draw_lines_curvy(line_img, lines)
return line_img

def weighted_img(img, initial_img, α=0.8, β=1., λ=0.):

return cv2.addWeighted(initial_img, α, img, β, λ)

import os
os.listdir("test_images/")

img = mpimg.imread('test_images/solidWhiteCurve.jpg')
img_shape= img.shape
img_gray = grayscale(img)
img_blur = gaussian_blur(img_gray, kernel_size=5)
img_edge = canny(img_blur, low_threshold=50, high_threshold=150)
vertices = np.array([[(0,img_shape[0]),(425, 315), (540, 315),
(img_shape[1],img_shape[0])]], dtype=np.int32)
img_masked_edges = region_of_interest(img_edge, vertices)
img_hough_lines = hough_lines(img_masked_edges, rho=1, theta=np.pi/180,
thresh-old=40,
min_line_len=60, max_line_gap=20)
img_lanes = weighted_img(img=img_hough_lines, initial_img=img, α=0.8, β=1.,
λ=0.)
plt.imshow(img_lanes)

img_hough_lines_extrapolated = hough_lines(img_masked_edges, rho=1,


theta=np.pi/180, threshold=40,
min_line_len=60, max_line_gap=20,
extrapolate=True)
img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated, ini-
tial_img=img, α=0.8, β=1., λ=0.)
plt.imshow(img_lanes_extrapolated)

img = mpimg.imread('test_images/solidWhiteRight.jpg')
img_shape= img.shape
img_gray = grayscale(img)
img_blur = gaussian_blur(img_gray, kernel_size=5)
img_edge = canny(img_blur, low_threshold=50, high_threshold=150)
vertices = np.array([[(0,img_shape[0]),(425, 315), (540, 315),
(img_shape[1],img_shape[0])]], dtype=np.int32)
img_masked_edges = region_of_interest(img_edge, vertices)
img_hough_lines = hough_lines(img_masked_edges, rho=1, theta=np.pi/180,
thresh-old=40,
min_line_len=60, max_line_gap=40)
img_lanes = weighted_img(img=img_hough_lines, initial_img=img, α=0.8, β=1.,
λ=0.)
plt.imshow(img_lanes)

img_hough_lines_extrapolated = hough_lines(img_masked_edges, rho=1,


theta=np.pi/180, threshold=40,
min_line_len=60, max_line_gap=40,
extrapolate=True)
img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated, ini-
tial_img=img, α=0.8, β=1., λ=0.)
plt.imshow(img_lanes_extrapolated)

img = mpimg.imread('test_images/solidYellowCurve.jpg')
img_shape= img.shape
img_gray = grayscale(img)
img_blur = gaussian_blur(img_gray, kernel_size=5)
img_edge = canny(img_blur, low_threshold=50, high_threshold=150)
vertices = np.array([[(0,img_shape[0]),(425, 315), (540, 315),
(img_shape[1],img_shape[0])]], dtype=np.int32)
img_masked_edges = region_of_interest(img_edge, vertices)
img_hough_lines = hough_lines(img_masked_edges, rho=1, theta=np.pi/180,
thresh-old=40,
min_line_len=60, max_line_gap=30)
img_lanes = weighted_img(img=img_hough_lines, initial_img=img, α=0.8, β=1.,
λ=0.)
plt.imshow(img_lanes)

img_hough_lines_extrapolated = hough_lines(img_masked_edges, rho=1,


theta=np.pi/180, threshold=40,
min_line_len=60, max_line_gap=30,
extrapolate=True)
img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated, ini-
tial_img=img, α=0.8, β=1., λ=0.)
plt.imshow(img_lanes_extrapolated)

img = mpimg.imread('test_images/solidYellowCurve2.jpg')
img_shape= img.shape
img_gray = grayscale(img)
img_blur = gaussian_blur(img_gray, kernel_size=5)
img_edge = canny(img_blur, low_threshold=50, high_threshold=150)
vertices = np.array([[(0,img_shape[0]),(425, 315), (540, 315),
(img_shape[1],img_shape[0])]], dtype=np.int32)
img_masked_edges = region_of_interest(img_edge, vertices)
img_hough_lines = hough_lines(img_masked_edges, rho=1, theta=np.pi/180,
thresh-old=60,
min_line_len=60, max_line_gap=30)
img_lanes = weighted_img(img=img_hough_lines, initial_img=img, α=0.8, β=1.,
λ=0.)
plt.imshow(img_lanes)

img_hough_lines_extrapolated = hough_lines(img_masked_edges, rho=1,


theta=np.pi/180, threshold=60,
min_line_len=60, max_line_gap=30,
extrapolate=True)
img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated, ini-
tial_img=img, α=0.8, β=1., λ=0.)
plt.imshow(img_lanes_extrapolated)

img = mpimg.imread('test_images/solidYellowLeft.jpg')
img_shape= img.shape
img_gray = grayscale(img)
img_blur = gaussian_blur(img_gray, kernel_size=5)
img_edge = canny(img_blur, low_threshold=50, high_threshold=150)
vertices = np.array([[(0,img_shape[0]),(425, 315), (540, 315),
(img_shape[1],img_shape[0])]], dtype=np.int32)
img_masked_edges = region_of_interest(img_edge, vertices)
img_hough_lines = hough_lines(img_masked_edges, rho=1, theta=np.pi/180,
thresh-old=60,
min_line_len=60, max_line_gap=30)
img_lanes = weighted_img(img=img_hough_lines, initial_img=img, α=0.8, β=1.,
λ=0.)
plt.imshow(img_lanes)
img_hough_lines_extrapolated = hough_lines(img_masked_edges, rho=1,
theta=np.pi/180, threshold=60,
min_line_len=60, max_line_gap=30,
extrapolate=True)
img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated, ini-
tial_img=img, α=0.8, β=1., λ=0.)
plt.imshow(img_lanes_extrapolated)

img = mpimg.imread('test_images/whiteCarLaneSwitch.jpg')
img_shape= img.shape
img_gray = grayscale(img)
img_blur = gaussian_blur(img_gray, kernel_size=5)
img_edge = canny(img_blur, low_threshold=50, high_threshold=150)
vertices = np.array([[(0,img_shape[0]),(425, 315), (540, 315),
(img_shape[1],img_shape[0])]], dtype=np.int32)
img_masked_edges = region_of_interest(img_edge, vertices)
img_hough_lines = hough_lines(img_masked_edges, rho=1, theta=np.pi/180,
thresh-old=80,
min_line_len=60, max_line_gap=30)
img_lanes = weighted_img(img=img_hough_lines, initial_img=img, α=0.8, β=1.,
λ=0.)
plt.imshow(img_lanes)

img_hough_lines_extrapolated = hough_lines(img_masked_edges, rho=1,


theta=np.pi/180, threshold=80,
min_line_len=60, max_line_gap=30,
extrapolate=True)
img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated, ini-
tial_img=img, α=0.8, β=1., λ=0.)
plt.imshow(img_lanes_extrapolated)

from moviepy.editor import VideoFileClip


from IPython.display import HTML

def process_image(image):

img_shape= image.shape
img_gray = grayscale(image)

img_blur = gaussian_blur(img_gray, kernel_size=5)


img_edge = canny(img_gray, low_threshold=50, high_threshold=100)
vertices = np.array([[(img_shape[1]*0.20,img_shape[0]),(img_shape[1]*0.40,
img_shape[0]*0.60),
(img_shape[1]*0.55, img_shape[0]*0.60),
(img_shape[1],img_shape[0])]], dtype=np.int32)

img_masked_edges = region_of_interest(img_edge, vertices)

img_hough_lines_extrapolated = hough_lines(img_masked_edges,
rho=1, theta=np.pi/180, threshold=40,
min_line_len=10, max_line_gap=70,
extrapolate=True)

img_lanes_extrapolated = weighted_img(img=img_hough_lines_extrapolated,
initial_img=image, α=0.8, β=1., λ=0.)
return img_lanes_extrapolated
white_output = 'white.mp4'
clip1 = VideoFileClip("solidWhiteRight.mp4")
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color
images!!
get_ipython().run_line_magic('time',
'white_clip.write_videofile(white_output, audio=False)')

yellow_output = 'yellow.mp4'
clip2 = VideoFileClip('solidYellowLeft.mp4')
yellow_clip = clip2.fl_image(process_image)
get_ipython().run_line_magic('time',
'yellow_clip.write_videofile(yellow_out-put, audio=False)')
REFERENCES

1) Lane detection using Randomized Hough Transform


Peerawat Mongkonyong1,*, Chaiwat Nuthong 1, Supakorn Siddhichai2
and Masaki Yamakita3

1 International College, King Mongkuts Institute of Technology Ladkrabang


(KMITL), Bangkok 10520, Thailand
2 National Electronics and Computer Technology Center (NECTEC)
3 Tokyo Institute of Technology, Tokyo (Tokyo Tech)
* Corresponding Author: [email protected], 0822087697
http://iopscience.iop.org/article/10.1088/1757-899X/297/1/012050/pdf

2) Improved Lane Line Detection Algorithm Based on Hough Transform Fang


Zheng*, Sheng Luo**, Kang Song, Chang-Wei Yan, and Mu-Chou Wang
Mechanical and Electrical Engineering College, WenZhou University, WenZhou,
CN-325016 China *e-mail: [email protected]
**e-mail: [email protected]

3) Finding Lane Lines on the Road


Naoki Shibuya - Research Engineer @ Ascent Robotics
https://towardsdatascience.com/finding-lane-lines-on-the-road-30cf016a1165

You might also like