A rule-based computer vision pipeline for detecting lane boundaries using edge detection, region filtering, and polynomial regression, with LiDAR support for poor lighting conditions.
- Edge Detection: Canny edge detection with Gaussian blur preprocessing
- Region of Interest: Dynamic ROI filtering for lane-relevant areas
- Hough Transform: Line detection using probabilistic Hough transform
- Polynomial Fitting: 2nd-degree polynomial regression for smooth lane curves
- LiDAR Integration: Point cloud processing to supplement visual data
- Real-time Processing: Video and webcam support
- Python
- OpenCV
- NumPy
- Point Cloud Library (PCL) concepts
A simple, rule-based lane detection pipeline written in Python using OpenCV and NumPy. The project demonstrates a classic computer vision approach: preprocessing, edge detection, region masking, line extraction with Hough transform, and polynomial fitting to draw smooth lane overlays on video frames.
lane_detection.py— Main lane detection pipeline (video/webcam)lidar_functions.py— LiDAR-related helpers (if present)requirements.txt— Python dependencies
- (Optional) Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the detector from a webcam:
python lane_detection.py
Or run on a video file:
python lane_detection.py path/to/video.mp4
Press q to quit the preview window.
- Python 3.8+
- opencv-python
- numpy
See requirements.txt for exact packages.
- Convert frames to grayscale and blur to reduce noise.
- Run Canny edge detection and mask the image to a trapezoidal ROI.
- Detect line segments with the probabilistic Hough transform.
- Separate left/right candidate lines by slope and position.
- Fit a 2nd-degree polynomial to each lane side for a smooth curve.
- Draw lane lines and a filled lane region overlay on the original frame.
- Canny thresholds (currently 50, 150)
- Gaussian blur kernel size
- Hough transform params:
rho,theta,threshold,minLineLength,maxLineGap - Slope filtering threshold (used when separating left/right lines)
This README and non-functional cleanups were produced with assistance from the AI tool GitHub Copilot. The core project code and algorithm design remain the repository owner's work. AI was used to help improve documentation and add a dependency file.
- Add unit tests and small sample videos under
tests/. - Add a CLI flag to save output video or images.
- Add more robust temporal smoothing for fitted lane curves.
If you'd like, I can help prepare a branch and push these changes to the remote repository (you'll need to run the git commands locally or provide remote access).