This project demonstrates the implementation of a self-driving car agent using classic image processing techniques and deep learning aproaches. The agent is designed to drive between lanes and avoid obstacles in a simulated environment, specifically the Avis Engine Driving Simulator.
The main components of this project include:
Lane detection
usingimage thresholding
.Perspective transformation
to achieve a bird's-eye view of the road.- `Calculation of the steering angle based on the detected lane lines.
Obstacle avoidance
using sensor data and lane information.
selfdriving_car_agent.webm
Lane Detection
: Usesimage thresholding
and line detection to identify lane markings on the road.Perspective Transformation
: Transforms the camera's view into abird's-eye perspective
for more accurate lane detection.Steering Angle Calculation
: Determines the optimal steering angle to keep the car within the lanes.Obstacle Avoidance
: Adjusts the car's trajectory to avoid obstacles detected by the car's sensors.Dynamic Speed Control
: Adjusts the car's speed based on the curvature of the road and proximity to obstacles.
- Python 3.x
- OpenCV
- NumPy
- Avis Engine Driving Simulator
- first you need to install avis driving simulator
- install the required Python packages
First open the avis driving simulator and select the race road. Then Start the server and increase the max speed to 100. To run the self-driving car agent, execute the following command:
python main.py
bird_eye_view(image)
: Applies a perspective transformation to obtain a bird's-eye view of the road.extract_lines(image)
: Extracts the lane lines from the transformed image using HSV thresholding.find_first_left_point(line, mask)
: Identifies the first point on the left lane line.find_first_right_point(line, mask)
: Identifies the first point on the right lane line.drive_in_lines(left, right, center)
: Calculates the steering angle to keep the car between the lane lines.get_over_obstacle(mask, left, right, center, flag, frame)
: Determines the car's maneuver to avoid an obstacle.cal_speed(car_angle)
: Dynamically adjusts the car's speed based on the steering angle.
main.py
: Contains the main loop to run the self-driving car agent.lane_detection.py
: Handles the image processing tasks such as lane detection and perspective transformation.steering_control.py
: Manages the steering angle calculation and speed control.
Special thanks to the Avis Engine team for providing the driving simulator. The project uses OpenCV for image processing and NumPy for numerical computations.