Skip to content

devikabraj08-ai/opencv-lane-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗 OpenCV Lane Detection

A real-time lane detection system developed using Python, OpenCV, and NumPy. The project detects road lane boundaries from a driving video, highlights the driving lane, estimates the vehicle's position relative to the lane centre, and provides a basic steering suggestion.


📌 Features

  • Real-time lane detection
  • Region of Interest (ROI) selection
  • Gaussian Blur for noise reduction
  • Canny Edge Detection
  • Hough Line Transform for lane detection
  • Lane fitting using linear regression
  • Temporal smoothing for stable lane tracking
  • Lane area visualization
  • Lane centre estimation
  • Vehicle centre estimation
  • Vehicle offset calculation
  • Steering direction suggestion
  • FPS (Frames Per Second) display

🛠️ Technologies Used

  • Python 3
  • OpenCV
  • NumPy

📂 Project Structure

opencv-lane-detection/
│
├── input/
│   └── road_car_view.mp4
│
├── output/
│   ├── output.mp4
│   ├── straight_road_detection.png
│   └── curved_road_detection.png
│
├── lane_detection.py
├── requirements.txt
├── README.md
└── .gitignore

⚙️ Algorithm Workflow

  1. Read video frames
  2. Convert frame to grayscale
  3. Apply Gaussian Blur
  4. Detect edges using Canny Edge Detection
  5. Apply Region of Interest (ROI)
  6. Detect lane segments using Hough Line Transform
  7. Separate left and right lane lines
  8. Fit lane lines using linear regression
  9. Apply temporal smoothing
  10. Draw lane boundaries and lane area
  11. Calculate lane centre and vehicle centre
  12. Estimate vehicle offset
  13. Display steering suggestion and FPS

📷 Results

Straight Road Detection

Straight Road Detection

Curved Road Detection

Straight Road Detection

🎥 Demo Video

[▶️ Watch the Full Demo Video](## 🎥 Demo Video

▶️ Watch the Full Demo Video)


▶️ Installation

Clone the repository:

git clone https://github.com/<devikabraj08-ai>/opencv-lane-detection.git

Move into the project directory:

cd opencv-lane-detection

Install the required packages:

pip install -r requirements.txt

▶️ Usage

Run the project:

python lane_detection.py

Press Q to exit the application center.


📈 Future Improvements

  • Adaptive Region of Interest
  • Curved lane detection using polynomial fitting
  • Perspective (Bird's-Eye View) transformation
  • Lane departure warning system
  • Camera calibration for improved accuracy
  • Deep learning-based lane detection

👩‍💻 Author

Devika B Raj

B.Tech in Robotics and Automation

GitHub: https://github.com/

LinkedIn: https://www.linkedin.com/in/devika-b-raj-778785329/

About

Real-time lane detection using OpenCV, NumPy, Canny Edge Detection, and Hough Line Transform.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages