🚗 Autonomous Driving Car Detection using YOLO
📚 Overview
This project utilizes YOLO (You Only Look Once), a state-of-the-art object detection algorithm, to detect cars in real-time video streams or images. It demonstrates the application of deep learning and computer vision in autonomous driving systems.
🎯 Objective
Detect and classify cars in real-time.
Enable precise localization of detected objects.
Provide a foundation for building advanced autonomous driving applications.
🛠️ Technologies Used
Deep Learning Framework: TensorFlow
Object Detection Algorithm: YOLO (You Only Look Once)
Programming Language: Python
Libraries: OpenCV, NumPy
🚀 Implementation Steps
1️⃣ Install Required Libraries
pip install tensorflow opencv-python numpy
2️⃣ Load YOLO Model
import cv2
import numpy as np
net = cv2.dnn.readNet('yolov3.weights', 'yolov3.cfg')
layer_names = net.getLayerNames()
output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]
3️⃣ Detect Cars from Video Stream
cap = cv2.VideoCapture('video.mp4')
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
height, width, channels = frame.shape
blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), swapRB=True, crop=False)
net.setInput(blob)
outs = net.forward(output_layers)
4️⃣ Display Detected Cars
for out in outs:
for detection in out:
scores = detection[5:]
class_id = np.argmax(scores)
confidence = scores[class_id]
if confidence > 0.5:
center_x = int(detection[0] * width)
center_y = int(detection[1] * height)
w = int(detection[2] * width)
h = int(detection[3] * height)
cv2.rectangle(frame, (center_x, center_y), (w, h), (0, 255, 0), 2)
cv2.imshow('Car Detection', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
📈 Results
Successfully detected cars in both static images and video streams.
Achieved real-time detection speeds with YOLO’s optimized architecture.
📜 License
This project is licensed under the MIT License
🤝 Contributions
Contributions are welcome! Feel free to open an issue or submit a pull request.
There are no datasets linked
There are no datasets linked