Repository
Car-parking-slot-detector
A robust computer vision solution to detect and monitor parking slot occupancy in real-time.
๐ 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!