Lane-Detection
A sophisticated lane detection system using advanced computer vision techniques in Python. The application can detect lane lines in both images and video streams, demonstrating robust lane line identification across various driving conditions.
Advanced Lane Detection with Computer Vision
Project Overview
This project implements a sophisticated lane detection system using advanced computer vision techniques in Python. The application can detect lane lines in both images and video streams, demonstrating robust lane line identification across various driving conditions.
Features
- Detect white and yellow lane lines in different color spaces
- Process images and video streams in real-time
- Apply multiple image processing techniques:
- Color selection
- Grayscale conversion
- Gaussian smoothing
- Canny edge detection
- Region of interest selection
- Hough line transformation
- Adaptive lane line drawing with slope and length weighting
Prerequisites
- Python 3.7+
- Libraries:
- OpenCV (
cv2) - NumPy
- Matplotlib
- MoviePy
- OpenCV (
Installation
Clone the repository:
git clone https://github.com/yourusername/lane-detection.git cd lane-detectionInstall required dependencies:
pip install opencv-python numpy matplotlib moviepy
Detailed Processing Pipeline
The lane detection pipeline consists of several key stages:
Color Space Conversion
- Convert images to different color spaces (RGB, HSV, HSL)
- Isolate lane line colors (white and yellow)
Image Preprocessing
- Convert to grayscale
- Apply Gaussian blur to reduce noise
- Detect edges using Canny edge detection
Region of Interest Selection
- Mask out irrelevant parts of the image
- Focus on the road ahead
Line Detection
- Use Hough Transform to identify line segments
- Compute line slopes and intercepts
- Distinguish between left and right lane lines
Lane Line Rendering
- Draw smooth, continuous lane lines
- Overlay detected lines on original image/video
Example Usage
Image Lane Detection
# Process a single image
result = frame_processor(input_image)
plt.imshow(result)
plt.show()
Video Lane Detection
# Process a video file
process_video('input_video.mp4', 'output_video.mp4')
Detailed Functions
Key Functions
HSL_color_selection(): Color-based lane line isolationcanny_detector(): Edge detectionregion_selection(): Focus area determinationhough_transform(): Line segment identificationlane_lines(): Compute full lane line coordinatesdraw_lane_lines(): Render lane lines on image
Limitations and Potential Improvements
- Performance may vary in challenging lighting conditions
- Sensitive to camera positioning and road surface
- Does not handle curved lanes optimally
Output Images
https://github.com/user-attachments/assets/89383980-80be-4d20-9aad-b0cc0b04ddab
Example image:
https://github.com/user-attachments/assets/8cc39266-5565-4d77-9d5f-28aab7ae776d
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a pull request
License
This project is open-source, licensed under the MIT License.
Acknowledgments
- OpenCV Community
- Computer Vision research resources
References
- Udacity Self-Driving Car Nanodegree Program
- OpenCV Documentation
- Advanced Lane Detection Techniques in Computer Vision
Contact
For questions or collaboration, please open an issue or contact Utso Sarkar.