SlideShare a Scribd company logo
Udacity Self Driving Cars Nanodegree- Advanced Lane Finding Project
Objective:
The objective is to write a Python program to identify the lane boundaries in a video from a front-facing
camera on a car. The camera calibration images, test road images, and project videos are provided.
Steps:
1. Removing Distortion
2. Isolate Lanes
3. Warp
4. Curve Fit
5. Final Image
1. Removing distortion:
Cameras use lens which distort image. OpenCV provides function to correct these distortions and to
calibrate the camera.
A set of 20 chess board images were used to calibrate camera.
First, a set of chess board image are passed to findChessboardCorners function to get the corner
points, thru the following code:
Ret, corners=cv2.findChessboardCorners (gray, (9, 6), None)
Then, the corner points discovered are passed to the calibrate Camera function, thru the following
code:
Ret,mtx,dist,rvecs,tvecs=cv2.calibrateCamera(objpoints,imgpoints,gray.shape[::-1],None,None)
This function returns the camera matrix and the distortion coefficients which are then passed to
undistort function to correct the distortion of the images, thru the following code:
undist=cv2.undistort(img,mtx,dist,None,mtx)
The following image shows the Original image and the undistorted image side by side:
2. Isolate Lanes:
Then, color and direction gradients are applied to isolate lanes. Color spaces (RGB, HSV, HLS, LAB, etc.)
are explored for the images to see which channels of these color spaces may be used to distinguish
lane markings based on colors. In our example, S channel of HLS color space and V channel of the HSV
color space was used.
Then, direction gradient (Sobel filter) is used to detect lanes based on change of intensity (edge
detection) where lane markings exists. Both color channels and Sobel filters are applied with the
appropriate thresholds to isolate lane lines.
OpenCV provides cvtColor function to convert the image to different color spaces, like the following
conversion to HLS and HSV color spaces:
hls=cv2.cvtColor (RGB, cv2.COLOR_RGB2HLS) hsv=cv2.cvtColor(img,cv2.COLOR_RGB2HSV)
The following image shows the image after passed to Sobel x operator (with the appropriate
threshold):
The following image shows the image after passed to Sobel y operator (with the appropriate
threshold):
The following image shows the image after passed thru the Color spaces (S channel of HLS and V
channel of HSV):
The following image shows the image after passed thru the combination of Sobel and Color spaces
channels thresholds:
3. Warp:
Source and destination points are passed to the getPerspective function, thru the following code:
M=cv2.getPerspectiveTransform (src, dst)
This results in a Transformation Matrix M, which along with the original image is passed to the
warpPerspective function to get a bird’s eye view (warped perspective) of the image. Following code is
used:
Warped=cv2.warpPerspective(img,M,img_size)
The following image shows Undistorted image with Source points drawn along with the Warped image
with destination points drawn:
4. Curve Fit:
Find the left and the right lines and then apply curve fit to those lines.
We take a histogram of the bottom half of the image and we determine where the lane lines start based
on wherever the histogram peaks are. Y value is sum of the pixels at that x location and the 2 maximums
are where the lines start.
Following code is used:
Histogram=np.sum(img[img.shape[0]//2:,:],axis=0]
Leftx_base=np.argmax(histogram[:midpoint])
Rightx_base=np.argmax(histogram[midpoint:]+midpoint Following
image shows histogram output:
Then, we use a sliding windows technique described as follows: we draw a box around the lane starting
points and any of the white pixels from the binary image that fall into that box; we put them in a list of
x and y values. Then, we add a box on top of that and do the same thing and as we move up the lane
line; we will move the boxes to the left or right based on the average of the previous line. At the end of
this; we will have lists of x and y values of the pixels that are in the line and then we run the 2nd order
numpy polyfit to those pixels to get the curve fit in the pixel space. Following code is used:
Left_fit=np.polyfit(lefty,leftx,2) Right_fit=np.polyfit(righty,rightx,2)
We then do the pixel to meters conversion based on US Highway standards (lanes are 12 feet wide).
After the first window frame; instead of the sliding windows technique; we take the previous fit and
move it to left and right by 100 pixels and any pixels (minimum 50) found in that area are added to the
list of x and y values and then we run the polyfit function to get the lane lines.
The following image shows curve fit with sliding windows technique.
The following image shows curve fit where the program looks for the next lane point within 100 pixels of
the previous fit.
5. Final Image:
Then, we create the final image and put text (using putText function) on the image for the Radius of
curvature and the Distance to lane center; which are calculated using the following formulae:
Radius of curvature=([1+(dy/dx)^2]^3/2)/(d^2y/dx^2)
laneCenter=(rigthPos-leftPos)/2+leftPOs
distancetoCenter=laneCenter-imageCenter
Then, we plot the curve fits and green color the drive area onto the image using fillPoly and polylines
function as shown below:
Cv2.fillPoly(color_warp,np.int_([pts]),(0,255,0))
We want to overlay on the original image and not the warped image. So we need to unwarp the image
(using undistort function reversing the source and destination points) and then add to the original
(using addWeighted function) as below.
Result=cv2.addWeighted(img,1,newwarp,0.5,0)
The following image shows the final drawn image with color filled between the lane lines.
The following image shows the final drawn image with color filled between the lane lines; and text
illustrating radius of curvature and distance from center.
Improvement Points:
There is lot of manual effort in the following areas; so the program will not scale well for all videos and
images:
1. Selection of best channels from the color spaces, which are used for lanes detection
2. Selection of thresholds (minimum and maximum) and parameters (example, kernel size) for
Sobel filter and for color spaces
3. Selection of source and destination points for perspective transform
A deep learning/machine learning approach will be more appropriate for the above points; so the
program can learn those parameters itself; rather than we manually specifying or selecting those
parameters.

More Related Content

What's hot

Computer Graphics Concepts
Computer Graphics ConceptsComputer Graphics Concepts
Computer Graphics Concepts
SHAKOOR AB
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics Functions
SHAKOOR AB
 
Feature Extraction
Feature ExtractionFeature Extraction
Feature Extraction
Revathi Krishnan
 
ECE 565 Project1
ECE 565 Project1ECE 565 Project1
ECE 565 Project1?? ?
 
Templateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer VisionTemplateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer Vision
shivam chaurasia
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
Kamal Acharya
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphics
Rafi_Dar
 
Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics PracticalNeha Sharma
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
Ashim Lamichhane
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
DataminingTools Inc
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
Priya Goyal
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
baabtra.com - No. 1 supplier of quality freshers
 
Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
DataminingTools Inc
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
Philip Schwarz
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
Omprakash Chauhan
 

What's hot (19)

Computer Graphics Concepts
Computer Graphics ConceptsComputer Graphics Concepts
Computer Graphics Concepts
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics Functions
 
Feature Extraction
Feature ExtractionFeature Extraction
Feature Extraction
 
ECE 565 Project1
ECE 565 Project1ECE 565 Project1
ECE 565 Project1
 
Templateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer VisionTemplateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer Vision
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphics
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Applets
AppletsApplets
Applets
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 

Similar to Writeup advanced lane_lines_project

Anish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_ReportAnish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_Reportanish h
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
Bhavya Chawla
 
Introduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABIntroduction to Image Processing with MATLAB
Introduction to Image Processing with MATLAB
Sriram Emarose
 
OpenCV presentation series- part 3
OpenCV presentation series- part 3OpenCV presentation series- part 3
OpenCV presentation series- part 3
Sairam Adithya
 
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
SamridhGarg
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
Aman Gupta
 
Shi.pdf
Shi.pdfShi.pdf
canvas.pptx
canvas.pptxcanvas.pptx
canvas.pptx
VeenaNaik23
 
We are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdfWe are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdf
DARSHANACHARYA13
 
Computer graphic
Computer graphicComputer graphic
Computer graphic
nusratema1
 
Primitives
PrimitivesPrimitives
05 contours seg_matching
05 contours seg_matching05 contours seg_matching
05 contours seg_matching
ankit_ppt
 
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionSimple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionAnish Patel
 
Estrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitaleEstrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitale
francescapadoin
 
Chapter v(drawing)
Chapter v(drawing)Chapter v(drawing)
Chapter v(drawing)
Chhom Karath
 

Similar to Writeup advanced lane_lines_project (20)

Anish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_ReportAnish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_Report
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
 
Introduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABIntroduction to Image Processing with MATLAB
Introduction to Image Processing with MATLAB
 
OpenCV presentation series- part 3
OpenCV presentation series- part 3OpenCV presentation series- part 3
OpenCV presentation series- part 3
 
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Shi.pdf
Shi.pdfShi.pdf
Shi.pdf
 
canvas.pptx
canvas.pptxcanvas.pptx
canvas.pptx
 
We are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdfWe are restricted from importing cv2 numpy stats and other.pdf
We are restricted from importing cv2 numpy stats and other.pdf
 
Computer graphic
Computer graphicComputer graphic
Computer graphic
 
Animation ppt
Animation pptAnimation ppt
Animation ppt
 
Primitives
PrimitivesPrimitives
Primitives
 
05 contours seg_matching
05 contours seg_matching05 contours seg_matching
05 contours seg_matching
 
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionSimple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
 
Estrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitaleEstrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitale
 
Report
ReportReport
Report
 
Chapter v(drawing)
Chapter v(drawing)Chapter v(drawing)
Chapter v(drawing)
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

Writeup advanced lane_lines_project

  • 1. Udacity Self Driving Cars Nanodegree- Advanced Lane Finding Project Objective: The objective is to write a Python program to identify the lane boundaries in a video from a front-facing camera on a car. The camera calibration images, test road images, and project videos are provided. Steps: 1. Removing Distortion 2. Isolate Lanes 3. Warp 4. Curve Fit 5. Final Image 1. Removing distortion: Cameras use lens which distort image. OpenCV provides function to correct these distortions and to calibrate the camera. A set of 20 chess board images were used to calibrate camera. First, a set of chess board image are passed to findChessboardCorners function to get the corner points, thru the following code: Ret, corners=cv2.findChessboardCorners (gray, (9, 6), None) Then, the corner points discovered are passed to the calibrate Camera function, thru the following code: Ret,mtx,dist,rvecs,tvecs=cv2.calibrateCamera(objpoints,imgpoints,gray.shape[::-1],None,None) This function returns the camera matrix and the distortion coefficients which are then passed to undistort function to correct the distortion of the images, thru the following code: undist=cv2.undistort(img,mtx,dist,None,mtx) The following image shows the Original image and the undistorted image side by side:
  • 2. 2. Isolate Lanes: Then, color and direction gradients are applied to isolate lanes. Color spaces (RGB, HSV, HLS, LAB, etc.) are explored for the images to see which channels of these color spaces may be used to distinguish lane markings based on colors. In our example, S channel of HLS color space and V channel of the HSV color space was used. Then, direction gradient (Sobel filter) is used to detect lanes based on change of intensity (edge detection) where lane markings exists. Both color channels and Sobel filters are applied with the appropriate thresholds to isolate lane lines. OpenCV provides cvtColor function to convert the image to different color spaces, like the following conversion to HLS and HSV color spaces: hls=cv2.cvtColor (RGB, cv2.COLOR_RGB2HLS) hsv=cv2.cvtColor(img,cv2.COLOR_RGB2HSV) The following image shows the image after passed to Sobel x operator (with the appropriate threshold):
  • 3. The following image shows the image after passed to Sobel y operator (with the appropriate threshold): The following image shows the image after passed thru the Color spaces (S channel of HLS and V channel of HSV):
  • 4. The following image shows the image after passed thru the combination of Sobel and Color spaces channels thresholds:
  • 5. 3. Warp: Source and destination points are passed to the getPerspective function, thru the following code: M=cv2.getPerspectiveTransform (src, dst) This results in a Transformation Matrix M, which along with the original image is passed to the warpPerspective function to get a bird’s eye view (warped perspective) of the image. Following code is used: Warped=cv2.warpPerspective(img,M,img_size) The following image shows Undistorted image with Source points drawn along with the Warped image with destination points drawn: 4. Curve Fit: Find the left and the right lines and then apply curve fit to those lines. We take a histogram of the bottom half of the image and we determine where the lane lines start based on wherever the histogram peaks are. Y value is sum of the pixels at that x location and the 2 maximums are where the lines start. Following code is used:
  • 6. Histogram=np.sum(img[img.shape[0]//2:,:],axis=0] Leftx_base=np.argmax(histogram[:midpoint]) Rightx_base=np.argmax(histogram[midpoint:]+midpoint Following image shows histogram output: Then, we use a sliding windows technique described as follows: we draw a box around the lane starting points and any of the white pixels from the binary image that fall into that box; we put them in a list of x and y values. Then, we add a box on top of that and do the same thing and as we move up the lane line; we will move the boxes to the left or right based on the average of the previous line. At the end of this; we will have lists of x and y values of the pixels that are in the line and then we run the 2nd order numpy polyfit to those pixels to get the curve fit in the pixel space. Following code is used: Left_fit=np.polyfit(lefty,leftx,2) Right_fit=np.polyfit(righty,rightx,2)
  • 7. We then do the pixel to meters conversion based on US Highway standards (lanes are 12 feet wide). After the first window frame; instead of the sliding windows technique; we take the previous fit and move it to left and right by 100 pixels and any pixels (minimum 50) found in that area are added to the list of x and y values and then we run the polyfit function to get the lane lines. The following image shows curve fit with sliding windows technique.
  • 8. The following image shows curve fit where the program looks for the next lane point within 100 pixels of the previous fit. 5. Final Image: Then, we create the final image and put text (using putText function) on the image for the Radius of curvature and the Distance to lane center; which are calculated using the following formulae: Radius of curvature=([1+(dy/dx)^2]^3/2)/(d^2y/dx^2) laneCenter=(rigthPos-leftPos)/2+leftPOs distancetoCenter=laneCenter-imageCenter Then, we plot the curve fits and green color the drive area onto the image using fillPoly and polylines function as shown below: Cv2.fillPoly(color_warp,np.int_([pts]),(0,255,0)) We want to overlay on the original image and not the warped image. So we need to unwarp the image (using undistort function reversing the source and destination points) and then add to the original (using addWeighted function) as below. Result=cv2.addWeighted(img,1,newwarp,0.5,0) The following image shows the final drawn image with color filled between the lane lines.
  • 9. The following image shows the final drawn image with color filled between the lane lines; and text illustrating radius of curvature and distance from center.
  • 10. Improvement Points: There is lot of manual effort in the following areas; so the program will not scale well for all videos and images: 1. Selection of best channels from the color spaces, which are used for lanes detection 2. Selection of thresholds (minimum and maximum) and parameters (example, kernel size) for Sobel filter and for color spaces 3. Selection of source and destination points for perspective transform A deep learning/machine learning approach will be more appropriate for the above points; so the program can learn those parameters itself; rather than we manually specifying or selecting those parameters.