All projects

Repository

Car-parking-slot-detector

A robust computer vision solution to detect and monitor parking slot occupancy in real-time.

View source Python0 stars ยท 0 forks

๐Ÿš— Parking Slot Detector using OpenCV

This project detects free and occupied parking slots from video footage using simple image processing techniques in OpenCV.

It includes two main scripts: - ParkingSpacePicker.py โ†’ Manually mark parking spaces on a parking lot image. - main.py โ†’ Detects free/occupied parking slots in real-time from a video.


๐Ÿ“‚ Project Structure

.
โ”œโ”€โ”€ 2nd/
โ”‚   โ”œโ”€โ”€ carParkImg.png     # Static image used for parking space selection
โ”‚   โ”œโ”€โ”€ carPark.mp4        # Video feed for parking lot
โ”‚   โ””โ”€โ”€ CarParkPos         # Saved parking positions (using pickle)
โ”œโ”€โ”€ ParkingSpacePicker.py  # Tool to manually draw/select parking slots
โ”œโ”€โ”€ main.py                # Main detection and counting program
โ”œโ”€โ”€ README.md              # Project documentation

๐Ÿ›  Requirements

  • Python 3.8+
  • OpenCV
  • cvzone
  • numpy

Install dependencies with:

pip install opencv-python cvzone numpy

โœจ How It Works

1. Select Parking Spaces

Run:

python ParkingSpacePicker.py
  • Left Click: Add a parking spot rectangle.
  • Right Click: Remove a rectangle.
  • Press Space to reset all spots.
  • Press Q to quit and save.

Parking spots are saved automatically into a CarParkPos file.


2. Run the Parking Slot Detector

Run:

python main.py
  • It processes video frame-by-frame.
  • Checks each marked parking space if it is occupied or free.
  • Displays "Free" vs "Occupied" slots with a live counter.

โš™๏ธ Configuration

You can easily adjust: - original_width, original_height: Size of parking slot rectangles. - scale: Resize factor for both the image and video to fit your screen.

Scaling ensures that rectangles drawn match exactly in both image and video.


๐Ÿง  Concepts Used

  • Image Thresholding
  • Contour Detection
  • Gaussian Blurring
  • Adaptive Thresholding
  • Parking Slot Area Cropping
  • Dynamic Rescaling

๐Ÿš€ Future Improvements

  • Automatic parking space detection using Deep Learning (YOLOv8, etc.)
  • Better handling for rainy/nighttime footage.
  • Flask web app for live monitoring.

๐Ÿ“œ License

This project is open-source and available under the MIT License.


Made with โค๏ธ using OpenCV and Python!