I got my inspiration from the way that Tesla's autopilot system worked. I wanted to create a way that anyone could be able to use those features on any car. It also works to create a safer driving experience.
My code identifies the lanes lines in a video or image and then outlines them in red, making it easy for a driver to stay inside of their lane, or see where they need to go.
I used the python opencv, cv2, and numpy libraries. The first step that I took was displaying the image and then converting that image into grayscale to make it easier to see the lines and cut down on processing power. I had to apply a Gaussian Blur to reduce the noise of the background and make the lane lines stand out. I used the Canny function to take the derivative of the function's x and y values to find the gradient and to measure the changes in all of the directions. I then had it outline the values where the gradient was the strongest. The stronger the gradient, the higher the change in brightness of the pixels, which would be where the lane line is located. Then I just created a function to display the lines and outlined them in red to make them stand out more. After that, using my image I created a triangular region where the lane lines started to form and used a mask to cover. At this point, I had multiple small lines being drawn, which isn't what I wanted, so I created a function that would find the average slope of the right and left lane lines and then only show one line for each side. The last step was I found a video online that showed the road continuously moving and I then drew the lane lines on there. I also used the Hough Transform to detect the lines on the video. The final step was I added a command so that when the input pressed the 'q' key on their keyboard the program would exit without crashing.
My main challenges were displaying the lines onto the video. I kept running into an issue where the video would just keep crashing. The problem was I wasn't breaking out of the loop and the lines would keep drawing even when the video was over. Another problem that I first had was multiple lines were being displayed, and I just wanted one. To solve this, I just created a function that would find the average of the lines.
I'm most proud of how I displayed the lane lines on the moving video.
I learned a lot about the opencv library. The intro to machine learning workshop was also super helpful, and I learned some things from that to implement in my project,
In the future, I think that it would be cool to add image recognition for stop signs, speed limits, and stoplight.