An intelligent parking space detection system powered by computer vision and deep learning
Features • Quick Start • For Students • How It Works • Contributing
Imagine you're managing a parking lot and need to know:
- ✅ How many parking spaces are empty right now?
- ✅ Which specific spots are available?
- ✅ How full is the parking lot over time?
This system does exactly that - automatically!
You provide an image or video of your parking lot, and the system:
- Lets you mark where the parking spaces are (just click and drag)
- Uses AI to detect cars in those spaces
- Shows you which spaces are empty (green) and occupied (red)
- Generates detailed reports with charts and statistics
No manual counting needed! The computer does all the work.
Input: Picture of parking lot with 50 spaces
Output: "35 spaces occupied, 15 available"
+ Visual map showing which spots are free
+ Detailed report with charts
+ CSV file for data analysis
- What Does This Do?
- For Students & Academic Use
- Overview
- Features
- Quick Start
- Step-by-Step Tutorial
- Detailed Setup
- Usage
- Configuration
- Project Structure
- How It Works
- Troubleshooting
- Contributing
- License
- Acknowledgments
This project is excellent for academic purposes because it demonstrates:
Computer Vision Concepts:
- Image processing (grayscale, blurring, thresholding)
- Object detection using deep learning (YOLOv8)
- Real-time video processing
- Color space transformations (RGB to HSV)
- Morphological operations
Software Engineering Skills:
- Clean code architecture
- Configuration management
- Error handling and logging
- File I/O operations
- CLI application development
Data Science & Analytics:
- Data collection and storage (CSV)
- Statistical analysis
- Data visualization (charts, graphs)
- Report generation
✅ Final Year Project - Complete system for smart parking ✅ Computer Vision Assignment - Object detection implementation ✅ Machine Learning Project - YOLO model application ✅ IoT Project - Combine with sensors for real-time monitoring ✅ Data Analysis Project - Analyze parking patterns over time ✅ Research Paper - Study parking occupancy patterns
After studying this project, you'll understand:
- How to use OpenCV for image processing
- How to apply YOLOv8 for object detection
- How to build interactive GUI applications
- How to generate professional reports
- How to structure a real-world Python project
- How to document code professionally
Week 1: Understand the basics (image processing, OpenCV)
Week 2: Study YOLO and object detection
Week 3: Run the project and experiment with parameters
Week 4: Modify and add your own features
Week 5: Create a presentation/report on your learnings
If you use this project in academic work, please cite:
Bharath K. (2024). Advanced Car Parking Space Detection System.
GitHub repository. https://github.com/8harath/Car-Parking-Detection
Note: This project was created for the PNT Lab selection process at IIT Tirupati Navishkar by Bharath K from Jain Deemed to be University.
This project provides a production-ready parking space detection system that combines classical computer vision techniques with state-of-the-art deep learning (YOLOv8) to analyze parking lots in real-time.
Perfect for:
- Academic projects and research
- Smart city applications
- Parking lot management systems
- Real-time parking guidance
- Parking analytics and reporting
- Learning computer vision and ML
✅ Real-time Detection - Process live video feeds or static images ✅ ML-Powered - YOLOv8 for accurate vehicle detection ✅ Interactive Setup - Drag-and-drop parking space selection ✅ Comprehensive Reports - Visual, text, and CSV outputs ✅ Special Parking Detection - Identifies disabled parking spaces ✅ Historical Tracking - CSV data logging for analytics ✅ Production Ready - Robust error handling and logging
- 🖱️ Drag-and-select multiple parking spaces at once
- 📐 Grid-based automatic space allocation
- 👁️ Visual feedback during selection
- ↩️ Undo/Redo functionality
- 🗑️ Right-click to remove individual spaces
- 🔍 Zoom and pan capabilities
- 🤖 YOLOv8-based deep learning model
- 🚙 Detects: Cars, Motorcycles, Buses, Trucks
- 📊 Confidence scores for each detection
- 🎯 Real-time detection capabilities
- 👀 Handles occlusions and partial visibility
- ⚡ GPU acceleration support
- 📈 Visual Reports: Multi-panel analytics dashboard
- 📝 Text Reports: Detailed statistics and metrics
- 💾 CSV Export: Historical data for analysis
- 🎨 Color-coded Display: Green (empty) / Red (occupied)
- ⏱️ Real-time statistics display
- 📊 Occupancy rate tracking
- ♿ Special parking space detection (yellow markings)
- 🔄 Video loop playback
- 📍 Precise coordinate tracking
- 🛡️ Robust error handling
- 📝 Comprehensive logging
- ⚙️ Centralized configuration
The system generates comprehensive reports with:
- Parking Lot Visualization - Color-coded parking spaces with occupancy status
- Statistics Dashboard - Bar charts showing total, occupied, and available spaces
- Space Type Distribution - Pie charts for regular vs. special parking
- Occupancy Analysis - Detailed breakdown by parking type
Reports are saved in reports/ directory with timestamp
Get up and running in under 5 minutes!
- Python 3.8 or higher
- pip package manager
- (Optional) CUDA-capable GPU for faster processing
# 1. Clone the repository
git clone https://github.com/8harath/Car-Parking-Detection.git
cd Car-Parking-Detection
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run the application
python run.py --image carParkImg.jpg- Select Parking Spaces: Click and drag to mark parking areas
- Save Layout: Press
Sto save your parking space configuration - Detect Vehicles: Press
Dto run detection and generate reports - View Results: Check the
reports/directory for outputs
Keyboard Shortcuts:
D- Detect vehicles & generate reportsS- Save parking layoutR- Reset all selectionsZ- Undo last selectionQ- Quit application
This tutorial assumes you've never used the system before. Follow these steps exactly:
# Open your terminal/command prompt
# Navigate to where you want to save the project
cd Desktop # or any folder you prefer
# Download the project
git clone https://github.com/8harath/Car-Parking-Detection.git
# Enter the project folder
cd Car-Parking-Detection
# Install required libraries
pip install -r requirements.txtWhat just happened? You downloaded the code and installed all the Python libraries it needs.
# Start the program
python run.py --image carParkImg.jpgWhat you'll see: A window will open showing a parking lot image.
This is the most important step! You need to tell the computer where the parking spaces are.
How to mark spaces:
- Click and hold your left mouse button at the top-left corner of a parking space
- Drag to the bottom-right corner of that space
- Release the mouse button
- You'll see a grid of purple rectangles appear - these are your marked spaces!
Tips:
- You can mark multiple spaces at once by dragging over them
- If you make a mistake, right-click on a space to remove it
- Press
Zto undo your last selection - Press
Rto start over completely
Practice: Try marking 5-10 spaces to get the hang of it.
Press 'S' on your keyboard
What happened? The computer saved your parking space positions. You won't have to mark them again!
Press 'D' on your keyboard
What happens:
- The screen will show: "🚗 Detecting vehicles..."
- The AI will analyze each parking space
- Green spaces = Empty
- Red spaces = Occupied
- Reports are generated automatically
The program creates several files for you:
1. Visual Report (reports/parking_report_YYYYMMDD_HHMMSS.png)
- Open this image to see charts and statistics
- Shows a colorful dashboard with graphs
2. Text Report (reports/parking_report_YYYYMMDD_HHMMSS.txt)
- Open with any text editor
- Contains detailed numbers and percentages
3. CSV Data (data/parking_status.csv)
- Open with Excel or Google Sheets
- Great for tracking over time
When you look at the visual report, you'll see:
┌─────────────────────────────────────────┐
│ Parking Lot Image (with colors) │
│ Green = Empty | Red = Occupied │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────┐
│ Bar Chart: Parking Statistics │
│ Shows total, occupied, available │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────┐
│ Pie Charts: Space Distribution │
│ Regular vs. Special parking │
└─────────────────────────────────────────┘
The text report tells you:
- Total number of parking spaces
- How many are occupied
- How many are available
- Occupancy percentage
- Timestamp of detection
Q: "Do I need to mark spaces every time I run it?"
A: No! Once you press S to save, the spaces are remembered. Next time just press D to detect.
Q: "Can I use my own parking lot image?"
A: Yes! Just use: python run.py --image path/to/your/image.jpg
Q: "What if I mark the wrong spot?"
A: Right-click on it to remove, or press Z to undo, or press R to reset everything.
Q: "How accurate is the detection?"
A: The AI (YOLOv8) is about 90-95% accurate. You can adjust sensitivity in config.py.
Q: "Can this work with a video?"
A: Yes! Use: python run.py --video your_video.mp4
Q: "Where are my reports saved?"
A: In the reports/ folder inside the project directory.
Once you're comfortable with the basics, try:
- Use your own images - Take a photo of any parking lot
- Adjust thresholds - Edit
config.pyto fine-tune detection - Try video mode - Process a video of a parking lot over time
- Analyze patterns - Open the CSV in Excel to see trends
- Modify the code - Add your own features!
Coming soon: YouTube video walkthrough
Minimum:
- Python 3.8+
- 4GB RAM
- 2GB free disk space
Recommended:
- Python 3.10+
- 8GB RAM
- NVIDIA GPU with CUDA support
- 5GB free disk space
# Create virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Unix or MacOS:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Create conda environment
conda create -n parking-detection python=3.10
conda activate parking-detection
# Install dependencies
pip install -r requirements.txt# Test imports
python -c "import cv2, numpy, pandas, ultralytics; print('✓ All dependencies installed')"
# Check GPU availability (optional)
python -c "import torch; print('CUDA available:', torch.cuda.is_available())"python run.py --image carParkImg.jpgpython run.py --video carPark.mp4from enhanced_parking_detector import EnhancedParkingDetector
# Initialize detector
detector = EnhancedParkingDetector(
image_path='path/to/image.png',
video_path='path/to/video.mp4'
)
# Process image
detector.process_image()
# Or process video
detector.process_video()Edit config.py:
# Adjust detection sensitivity
OCCUPANCY_THRESHOLD = 900 # Lower = more sensitive
CONFIDENCE_THRESHOLD = 0.5 # YOLOv8 confidence (0-1)
# Adjust parking space dimensions
PARKING_WIDTH = 107
PARKING_HEIGHT = 48All configuration is centralized in config.py:
| Parameter | Default | Description |
|---|---|---|
PARKING_WIDTH |
107 | Parking space width in pixels |
PARKING_HEIGHT |
48 | Parking space height in pixels |
OCCUPANCY_THRESHOLD |
900 | Pixel count threshold for occupancy |
CONFIDENCE_THRESHOLD |
0.5 | YOLOv8 detection confidence |
MODEL_PATH |
'yolov8n.pt' | Path to YOLO model |
CSV_APPEND_MODE |
True | Append to CSV vs. overwrite |
The system automatically creates:
reports/ # Generated reports
data/ # CSV data files
models/ # ML models
Car-Parking-Detection/
├── config.py # Centralized configuration
├── enhanced_parking_detector.py # Main detection logic
├── car_detector.py # YOLO-based vehicle detection
├── main.py # Video processing entry point
├── run.py # CLI entry point
├── setup_directories.py # Directory initialization
├── requirements.txt # Python dependencies
├── README.md # This file
├── TROUBLESHOOTING.md # Common issues and solutions
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
├── carParkImg.jpg # Sample parking lot image
├── carPark.mp4 # Sample parking lot video
├── CarParkPos # Saved parking positions
├── reports/ # Generated reports
│ ├── parking_report_YYYYMMDD_HHMMSS.png
│ └── parking_report_YYYYMMDD_HHMMSS.txt
└── data/ # CSV data files
└── parking_status.csv
┌─────────────────┐
│ Input │
│ (Image/Video) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Space Selection │
│ (Manual UI) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Image Processing│
│ (CV Pipeline) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Vehicle Detection│
│ (YOLOv8) │
└────────┬────────┘
│
▼
┌─────────────────┐
│Space Occupancy │
│ Analysis │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Report Generation│
│ (Visual/CSV) │
└─────────────────┘
-
Pre-processing
- Grayscale conversion
- Gaussian blur (noise reduction)
- Adaptive thresholding
- Median blur
- Morphological operations (dilation)
-
Vehicle Detection
- YOLOv8 inference on full image
- Filter for vehicle classes (car, truck, bus, motorcycle)
- Apply confidence threshold
- Match detections to parking spaces
-
Occupancy Analysis
- Extract each parking space region
- Count non-zero pixels
- Compare against threshold
- Mark as occupied/empty
-
Special Parking Detection
- Convert to HSV color space
- Detect yellow markings
- Identify horizontal/vertical lines
- Mark as special parking space
pip install opencv-pythonThe model will download automatically on first run. Ensure internet connection.
# In config.py, use CPU instead of GPU
# Or reduce image resolutionPress R to reset and redraw parking spaces. Make sure to press S to save.
For more issues, see TROUBLESHOOTING.md
Contributions are welcome! Here's how you can help:
- 🐛 Report Bugs: Open an issue with details
- 💡 Suggest Features: Share your ideas
- 🔧 Submit PRs: Fork, create branch, submit PR
- 📖 Improve Docs: Help us improve documentation
- ⭐ Star the Repo: Show your support!
# Fork and clone your fork
git clone https://github.com/YOUR_USERNAME/Car-Parking-Detection.git
# Create feature branch
git checkout -b feature/amazing-feature
# Make changes and commit
git commit -m "Add amazing feature"
# Push and create PR
git push origin feature/amazing-featureThis project is licensed under the MIT License - see the LICENSE file for details.
This project was implemented by Bharath K from Jain Deemed to be University as part of his project submission for the PNT Lab selection process conducted by IIT Tirupati Navishkar.
- Original Inspiration: Murtaza's Computer Vision Zone
- YOLOv8 Model: Ultralytics
- Libraries: OpenCV, PyTorch, Matplotlib, Pandas, NumPy
- 🏛️ IIT Tirupati Navishkar - For the selection process opportunity
- 🎓 Jain Deemed to be University - For academic support
- 👥 Open Source Community - For amazing tools and libraries
Bharath K 📧 Email: 8harath.k@gmail.com 🌐 Website: 8harath.me 💻 GitHub: @8harath
If you find this project useful, please consider giving it a ⭐!
- ✅ Core Features: Complete
- ✅ Documentation: Comprehensive
- ✅ Testing: In Progress
- 🔄 Continuous Improvement
Made with ❤️ by Bharath K