SlideShare a Scribd company logo
1 of 4
Download to read offline
How do self driving cars detects lane lines so easily
When we drive, we use our eyes to decide where to go. The lines on the road that show us where the lanes
are act as our constant reference for where to steer the vehicle. Naturally, one of the first things we would
like to do in developing a self-driving car is to automatically detect lane lines using an algorithm.
Since there are lots of companies developing autonomous cars, there are also variety of methods to
implement solutions for the self-driving car challenges.
Let’s review a simple 5-steps technique to detect lane lines using a dashboard camera located in the
vehicle. We’ll start with a static image, and then move to video stream.
Our original image looks like this:
1. The first step is to convert the images to Grayscale which return an image with only one color channel:
2. Apply Gaussian smoothing which is essentially a way of suppressing noise and spurious gradients by
averaging:
3. Apply Canny edge detection. The algorithm will first detect strong edge (strong gradient) pixels above
the high_threshold, and reject pixels below the low_threshold. Next, pixels with values between the
low_threshold and high_threshold will be included as long as they are connected to strong edges. The
output edges is a binary image with white pixels tracing out the detected edges and black everywhere
else:
4. Apply Hough Transform which gets the output from Canny and the result will be array of lines,
containing the endpoints (x1, y1, x2, y2) of all line segments detected by the transform operation.
Also, we need to determine ‘Region of interest’/ Region-Masking, to represent the vertices of a
quadrilateral region that we would like to retain for the color selection, while masking everything else
out.
5. Drawing the lines - In order to draw a single line on the left and right lanes, we need to create a
function that get the Hough array (step 4 outputs) and perform the following:
 Separate the Hough array into two arrays, for the left and right lines, according to the slope
(derived by the endpoints by using ((y2-y1)/(x2-x1)))
 Reject outliers slopes for each line according to a min and max values
 Calculate the mean slope for each line
 Extend the lines to fill all the slope, in this case I used simple multiplication with big negative and
positive values (*400 and *(-400))
 Calculate the mean of the new lines result with the previews lines (for the video streaming case)
for better smoothing
 Draw lines with color and combine it with the original image
In the above image we can observe how the function calculate the mean endpoints and slope for the left
line (on blue) and for the right line (on green). Then the function extend the lines (the black lines) where
some of the endpoints exceeding the boundaries of the picture. The Region-Masking step (marked on
yellow, the same as we used in the previous step) will cut the outliers edges, and the final output will be
as smoother as it can.
After processing this step on the Hough array (step 4) we will get the following image:
That’s it! we have the original image with the lane lines detected and marked in red.
Video streaming is just a collection of images. We can use video processing packages like "moviepy" to
run the model steps on all the ‘images’ in the video. An output example for the streaming video can be
found here
A link to the project can be found here. The Jupyter notebook running with Python 3.5 along with the
numpy and matplotlib libraries. I also used OpenCV ("Open-Source Computer Vision"), which is a
package that has many useful tools for analyzing images, and "moviepy" package for video processing.
Later I'll publish a follow-up post with more advanced techniques used to address the lane-lines challenge
PH. No. : +1-516-342-5749
Email ID : info@anolytics.ai
Thanks for reading,
Anolytics

More Related Content

What's hot

Geometry Shader
Geometry ShaderGeometry Shader
Geometry Shaderacbess
 
line and circle detection using hough transform
line and circle detection using hough transformline and circle detection using hough transform
line and circle detection using hough transformSaeed Ullah
 
4 pipeline computer graphics
4 pipeline computer graphics4 pipeline computer graphics
4 pipeline computer graphicscairo university
 
8 8b Trig Intro2
8 8b Trig Intro28 8b Trig Intro2
8 8b Trig Intro2taco40
 
Temporary Coherence 3D Animation
Temporary Coherence 3D AnimationTemporary Coherence 3D Animation
Temporary Coherence 3D AnimationAkshat Singh
 
Javascript Canvas API
Javascript Canvas APIJavascript Canvas API
Javascript Canvas APISamuel Santos
 
Chapter 1 drawing in auto cad 2010
Chapter 1   drawing in auto cad 2010Chapter 1   drawing in auto cad 2010
Chapter 1 drawing in auto cad 2010Shelly Wilke
 

What's hot (13)

Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Geometry Shader
Geometry ShaderGeometry Shader
Geometry Shader
 
line and circle detection using hough transform
line and circle detection using hough transformline and circle detection using hough transform
line and circle detection using hough transform
 
Robotics Navigation
Robotics NavigationRobotics Navigation
Robotics Navigation
 
4 pipeline computer graphics
4 pipeline computer graphics4 pipeline computer graphics
4 pipeline computer graphics
 
UNIT-III
UNIT-IIIUNIT-III
UNIT-III
 
8 8b Trig Intro2
8 8b Trig Intro28 8b Trig Intro2
8 8b Trig Intro2
 
UNIT-V
UNIT-VUNIT-V
UNIT-V
 
Clipping
ClippingClipping
Clipping
 
Temporary Coherence 3D Animation
Temporary Coherence 3D AnimationTemporary Coherence 3D Animation
Temporary Coherence 3D Animation
 
Javascript Canvas API
Javascript Canvas APIJavascript Canvas API
Javascript Canvas API
 
Chapter 1 drawing in auto cad 2010
Chapter 1   drawing in auto cad 2010Chapter 1   drawing in auto cad 2010
Chapter 1 drawing in auto cad 2010
 
Car1
Car1Car1
Car1
 

Similar to How do self driving cars detects lane lines so easily

LANE DETECTION USING IMAGE PROCESSING IN PYTHON
LANE DETECTION USING IMAGE PROCESSING IN PYTHONLANE DETECTION USING IMAGE PROCESSING IN PYTHON
LANE DETECTION USING IMAGE PROCESSING IN PYTHONIRJET Journal
 
Edge detection iOS application
Edge detection iOS applicationEdge detection iOS application
Edge detection iOS applicationKetan Raval
 
Advanced Lane Finding
Advanced Lane FindingAdvanced Lane Finding
Advanced Lane FindingBill Kromydas
 
Writeup advanced lane_lines_project
Writeup advanced lane_lines_projectWriteup advanced lane_lines_project
Writeup advanced lane_lines_projectManish Jauhari
 
Practical Digital Image Processing 3
 Practical Digital Image Processing 3 Practical Digital Image Processing 3
Practical Digital Image Processing 3Aly Abdelkareem
 
Features extraction for palmprint-based identification
Features extraction for palmprint-based identificationFeatures extraction for palmprint-based identification
Features extraction for palmprint-based identificationVito Gentile
 
Driver drowsiness and lane detection screenshots
Driver drowsiness and lane detection screenshotsDriver drowsiness and lane detection screenshots
Driver drowsiness and lane detection screenshotsVenkat Projects
 
Road signs detection using voila jone's algorithm with the help of opencv
Road signs detection using voila jone's algorithm with the help of opencvRoad signs detection using voila jone's algorithm with the help of opencv
Road signs detection using voila jone's algorithm with the help of opencvMohdSalim34
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancementRamin Anushiravani
 
License plate recognition
License plate recognitionLicense plate recognition
License plate recognitionrahul bhambri
 
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docxmercysuttle
 
05 contours seg_matching
05 contours seg_matching05 contours seg_matching
05 contours seg_matchingankit_ppt
 

Similar to How do self driving cars detects lane lines so easily (20)

LANE DETECTION USING IMAGE PROCESSING IN PYTHON
LANE DETECTION USING IMAGE PROCESSING IN PYTHONLANE DETECTION USING IMAGE PROCESSING IN PYTHON
LANE DETECTION USING IMAGE PROCESSING IN PYTHON
 
Edge detection iOS application
Edge detection iOS applicationEdge detection iOS application
Edge detection iOS application
 
SMOKE DETECTION ALARM.docx
SMOKE DETECTION ALARM.docxSMOKE DETECTION ALARM.docx
SMOKE DETECTION ALARM.docx
 
Mvs adas
Mvs adasMvs adas
Mvs adas
 
Advanced Lane Finding
Advanced Lane FindingAdvanced Lane Finding
Advanced Lane Finding
 
Writeup advanced lane_lines_project
Writeup advanced lane_lines_projectWriteup advanced lane_lines_project
Writeup advanced lane_lines_project
 
Practical Digital Image Processing 3
 Practical Digital Image Processing 3 Practical Digital Image Processing 3
Practical Digital Image Processing 3
 
Lane Detection
Lane DetectionLane Detection
Lane Detection
 
Features extraction for palmprint-based identification
Features extraction for palmprint-based identificationFeatures extraction for palmprint-based identification
Features extraction for palmprint-based identification
 
Driver drowsiness and lane detection screenshots
Driver drowsiness and lane detection screenshotsDriver drowsiness and lane detection screenshots
Driver drowsiness and lane detection screenshots
 
Animation
AnimationAnimation
Animation
 
Road signs detection using voila jone's algorithm with the help of opencv
Road signs detection using voila jone's algorithm with the help of opencvRoad signs detection using voila jone's algorithm with the help of opencv
Road signs detection using voila jone's algorithm with the help of opencv
 
OpenCV.pdf
OpenCV.pdfOpenCV.pdf
OpenCV.pdf
 
Report NIYANTRA
Report NIYANTRAReport NIYANTRA
Report NIYANTRA
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancement
 
License plate recognition
License plate recognitionLicense plate recognition
License plate recognition
 
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
 
05 contours seg_matching
05 contours seg_matching05 contours seg_matching
05 contours seg_matching
 
Da4201691696
Da4201691696Da4201691696
Da4201691696
 
Animation
AnimationAnimation
Animation
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 

How do self driving cars detects lane lines so easily

  • 1. How do self driving cars detects lane lines so easily When we drive, we use our eyes to decide where to go. The lines on the road that show us where the lanes are act as our constant reference for where to steer the vehicle. Naturally, one of the first things we would like to do in developing a self-driving car is to automatically detect lane lines using an algorithm. Since there are lots of companies developing autonomous cars, there are also variety of methods to implement solutions for the self-driving car challenges. Let’s review a simple 5-steps technique to detect lane lines using a dashboard camera located in the vehicle. We’ll start with a static image, and then move to video stream. Our original image looks like this: 1. The first step is to convert the images to Grayscale which return an image with only one color channel:
  • 2. 2. Apply Gaussian smoothing which is essentially a way of suppressing noise and spurious gradients by averaging: 3. Apply Canny edge detection. The algorithm will first detect strong edge (strong gradient) pixels above the high_threshold, and reject pixels below the low_threshold. Next, pixels with values between the low_threshold and high_threshold will be included as long as they are connected to strong edges. The output edges is a binary image with white pixels tracing out the detected edges and black everywhere else: 4. Apply Hough Transform which gets the output from Canny and the result will be array of lines, containing the endpoints (x1, y1, x2, y2) of all line segments detected by the transform operation. Also, we need to determine ‘Region of interest’/ Region-Masking, to represent the vertices of a quadrilateral region that we would like to retain for the color selection, while masking everything else out.
  • 3. 5. Drawing the lines - In order to draw a single line on the left and right lanes, we need to create a function that get the Hough array (step 4 outputs) and perform the following:  Separate the Hough array into two arrays, for the left and right lines, according to the slope (derived by the endpoints by using ((y2-y1)/(x2-x1)))  Reject outliers slopes for each line according to a min and max values  Calculate the mean slope for each line  Extend the lines to fill all the slope, in this case I used simple multiplication with big negative and positive values (*400 and *(-400))  Calculate the mean of the new lines result with the previews lines (for the video streaming case) for better smoothing  Draw lines with color and combine it with the original image In the above image we can observe how the function calculate the mean endpoints and slope for the left line (on blue) and for the right line (on green). Then the function extend the lines (the black lines) where
  • 4. some of the endpoints exceeding the boundaries of the picture. The Region-Masking step (marked on yellow, the same as we used in the previous step) will cut the outliers edges, and the final output will be as smoother as it can. After processing this step on the Hough array (step 4) we will get the following image: That’s it! we have the original image with the lane lines detected and marked in red. Video streaming is just a collection of images. We can use video processing packages like "moviepy" to run the model steps on all the ‘images’ in the video. An output example for the streaming video can be found here A link to the project can be found here. The Jupyter notebook running with Python 3.5 along with the numpy and matplotlib libraries. I also used OpenCV ("Open-Source Computer Vision"), which is a package that has many useful tools for analyzing images, and "moviepy" package for video processing. Later I'll publish a follow-up post with more advanced techniques used to address the lane-lines challenge PH. No. : +1-516-342-5749 Email ID : info@anolytics.ai Thanks for reading, Anolytics