A lane detection and autonomous target-point tracking system built for the CARLA Simulator. This project contains two separate scripts that together form a perception-to-control pipeline for CARLA's urban driving environment.
A straightforward lane detection implementation that mimics the classical OpenCV textbook approach. It connects to a running CARLA server, spawns an ego vehicle with camera sensors, and applies a basic image-processing pipeline to detect lane boundaries in real time.
Pipeline:
Camera Feed → Grayscale → Gaussian Blur → Canny Edges → ROI Mask → Hough Lines → Lane Overlay
This version includes a commented student-exercise block so the pipeline can be used as a teaching tool.
A more advanced script that extends the lane detection concept by computing a steering target point from the detected lane geometry. It handles vehicle spawning, sensor management, and closed-loop steering control within the CARLA simulation.
Shared initialization logic for connecting to the CARLA server and setting up the simulation world.
- Full CARLA Integration: Spawns ego vehicle, attaches sensors, manages simulation lifecycle
- Real-time Lane Detection: OpenCV-based pipeline processing at camera frame rate
- Target Point Tracking: Computes steering targets from detected lane geometry
- Interactive Controls: Keyboard-driven manual control with autopilot toggle
- Multi-sensor Support: Switchable camera views (RGB, Depth, Segmentation)
- Weather System: Dynamic weather presets for robustness testing
| Key | Action |
|---|---|
W / S |
Throttle / Brake |
A / D |
Steer Left / Right |
F1 |
Restart (respawn vehicle) |
F5 |
Toggle Autopilot |
TAB |
Toggle Camera View |
1-9 |
Switch Sensor Type |
F9 |
Toggle Recording |
ESC |
Quit |
- CARLA Simulator (Server running on
localhost:2000) - Python 3.7+
- Dependencies:
numpy,opencv-python,pygame,matplotlib
- Start the CARLA server (
CarlaUE4.exe) - Run the simple lane detection client:
python src/lane_detection.py- For target point tracking with autonomous steering:
python src/target_point_carla.pyautonomous-driving-carla/
├── src/
│ ├── lane_detection.py # Simple/primitive lane detection (classroom version)
│ ├── target_point_carla.py # Target point tracking + autonomous steering
│ └── init.py # CARLA client initialization
├── tests/
│ └── test_lane_detection.py # Unit tests for image processing functions
└── docs/
└── project_guidelines.pdf # Course project specification
MIT License