This project detects cars in a parking lot using YOLOv5, a popular object detection model. The code reads a video file, processes each frame, and identifies cars within a specified parking area. It then draws bounding boxes around the detected cars and displays the number of cars parked in the area.
-
Initialization: The code loads a pre-trained YOLOv5 model for object detection.
-
Video Capture: It opens a video file (e.g.,
parking.mp4) to process each frame. -
Detection: For each frame, it detects cars using the YOLOv5 model. If a car is detected within the specified parking area, a bounding box is drawn around it.
-
Display: The processed frame with bounding boxes and the number of cars detected in the parking area are displayed.
-
User Interaction: The program continues processing frames until the user presses the 'Esc' key to exit.
- Python 3.x
- PyTorch
- OpenCV
- YOLOv5 (pretrained weights)
- GPU (recommended for faster inference)
- Clone the repository and install dependencies.
- Download the pre-trained YOLOv5 model weights.
- Place your video file in the same directory as the code.
- Define the parking area polygon in the code.
- Run the script.
- Press 'Esc' to exit the video display.