A computer vision-based smart parking lot monitoring system that detects and tracks parking slot occupancy in real-time using OpenCV.
- Real-time Parking Detection - Analyzes video feeds to detect occupied and free parking slots
- Visual Slot Marker Tool - Interactive tool to define parking slot boundaries
- Edge & Pixel Analysis - Uses Canny edge detection and color variance to determine occupancy
- REST API - FastAPI endpoint to query parking status programmatically
- Live Statistics - Displays real-time count of free and occupied slots
- Web Dashboard - Real-time web interface with Flask & SocketIO
ParkVision/
βββ src/ # Core Python scripts
β βββ parking_analyzer.py # Main detection script
β βββ slot_marker.py # Interactive slot marking tool
β βββ api.py # FastAPI REST endpoint
βββ config/ # Configuration files
β βββ parking_slots.json # Slot coordinates (camera 1)
β βββ parking_slots2.json # Slot coordinates (camera 2)
βββ videos/ # Video files (not tracked in git)
β βββ carPark.mp4
β βββ 2.mp4
βββ web/ # Flask web application
β βββ app.py # Main Flask app with SocketIO
β βββ static/ # CSS and JavaScript
β βββ templates/ # HTML templates
βββ screenshots/ # Project screenshots
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT License
βββ README.md
- Python 3.8 or higher
- A parking lot video file (e.g.,
carPark.mp4)
-
Clone the repository
git clone https://github.com/MathewX470/ParkVision.git cd ParkVision -
Create a virtual environment (recommended)
python -m venv venv # Windows venv\Scripts\activate # Linux/macOS source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
Before analyzing a video, you need to define the parking slot boundaries:
python src/slot_marker.pyControls:
| Key | Action |
|---|---|
| Drag | Draw a rectangle to create a slot |
| F | Duplicate the last slot |
| W/S | Adjust vertical offset |
| A/D | Adjust horizontal offset |
| U | Undo last slot |
| P | Save and exit |
The slot coordinates are saved to config/parking_slots.json.
Analyze a parking lot video to detect occupancy:
python src/parking_analyzer.py- Green slots = Free π’
- Red slots = Occupied π΄
- Press ESC to exit
Start the Flask web server with real-time updates:
python web/app.pyAccess the dashboard at: http://localhost:5000
Start the FastAPI server to get parking status via REST:
uvicorn src.api:app --reloadAccess the API at: http://localhost:8000/parking/status
Example Response:
{
"total_slots": 15,
"free": 5,
"occupied": 10
}ParkVision uses a pixel-based analysis approach to determine slot occupancy:
- Edge Detection - Applies Canny edge detection to identify car outlines
- Color Variance - Calculates standard deviation of pixel values
- Threshold Comparison - Empty slots (asphalt) have low edge density and uniform color, while occupied slots (cars) show high edge density and varied colors
# Detection thresholds (adjustable)
edge_threshold = 8 # Edge density percentage
std_threshold = 35 # Color variance thresholdYou can tune the detection sensitivity by modifying these parameters in parking_analyzer.py:
| Parameter | Default | Description |
|---|---|---|
edge_threshold |
8 | Minimum edge density % to consider occupied |
std_threshold |
35 | Minimum color std dev to consider occupied |
- OpenCV - Computer vision and image processing
- NumPy - Numerical operations
- FastAPI - REST API framework
- Flask-SocketIO - Real-time WebSocket support (optional)
- Vehicle Size Detection - Classify vehicles as compact, sedan, SUV, or truck
- Smart Slot Recommendations - Suggest optimal parking spots based on vehicle size
- License Plate Recognition - Identify and track vehicles by license plate
- Parking Duration Tracking - Monitor how long vehicles have been parked
- Mobile App Integration - iOS/Android app for real-time parking availability
- Payment System Integration - Automated billing based on parking duration
- Multi-camera Support - Seamless stitching of multiple camera feeds
- Historical Analytics - Track parking patterns and peak hours
- Reservation System - Allow users to reserve parking spots in advance
- Accessibility Features - Highlight handicap-accessible spots
![]() Mathew Punnen Chandy |
![]() Vishak R |
![]() Johan Thomas Roby |
![]() Ashish Jacob |
Contributions are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.






