The project focusses on lane dectetion in images as well as in video using OpenCV. The pipeline is as below.
- The colour image or the video frame is converted into gray scale.
- Now a Gaussian Blur is added to the image with a kernel size of 5X5
- Now Canny edge detection algorithm is applied to this image to get the edges in the image. It uses a gradients to find out the edges.
- The threshold values are chosen between 50 and 150
- Now we crop the image to get more focus on the road section of the image thereby eliminating the sky areas.
- We use OpenCV fillPoly function to get the mask of the road surface and then bitwise and with the image from Canny.
- Now we have the edges of the roads and we need to connect the nearby edges to get the lanes
- We use Hough transform to get the lines with the parameters.
- rho=2
- theta=pi/180
- thresh=36
- min_line_length=38
- max_line_gap=43
Install cv2 library
Select the corresponding image file and run Project.py
For Easier tuning of hyper parameters for Hough Transform use Project1tune.py
For Videos select the appropriate video and run Projectvideo.py
The Challenge Video is solved by running Projectchallenge.py
Use only VLC player to open the video in Output.
The Code in Project.py works for all images with the hyperparameters for hough transform as above.
The Code in Projectvideo.py works for videos with the hyperparameters tuned for solidWhiteRight.mp4 and solidYellowLeft.mp4
The Code in Projectchallenge.py works for videos with hyperparameters tuned for challenge.mp4
The Output images and video are located in Output Folders
The current pipelines shows a major defect while gathering a distinction between the natural sunlight and marked lines on the road which is also white. Also the camera position plays a crucial role in the code stability, so that we don't need to change the change the boundaries of the polygon while masking the road surface in the image neglecting the sky areas.