Skip to content

MathewX470/ParkVision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— ParkVision

A computer vision-based smart parking lot monitoring system that detects and tracks parking slot occupancy in real-time using OpenCV.

Python OpenCV License

✨ Features

  • 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

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

  • Python 3.8 or higher
  • A parking lot video file (e.g., carPark.mp4)

Installation

  1. Clone the repository

    git clone https://github.com/MathewX470/ParkVision.git
    cd ParkVision
  2. Create a virtual environment (recommended)

    python -m venv venv
    
    # Windows
    venv\Scripts\activate
    
    # Linux/macOS
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt

πŸ“– Usage

Step 1: Mark Parking Slots

Before analyzing a video, you need to define the parking slot boundaries:

python src/slot_marker.py

Controls:

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.

Step 2: Run the Parking Analyzer

Analyze a parking lot video to detect occupancy:

python src/parking_analyzer.py
  • Green slots = Free 🟒
  • Red slots = Occupied πŸ”΄
  • Press ESC to exit

Step 3: Run the Web Dashboard

Start the Flask web server with real-time updates:

python web/app.py

Access the dashboard at: http://localhost:5000

Step 4: Query via API (Optional)

Start the FastAPI server to get parking status via REST:

uvicorn src.api:app --reload

Access the API at: http://localhost:8000/parking/status

Example Response:

{
  "total_slots": 15,
  "free": 5,
  "occupied": 10
}

βš™οΈ How It Works

ParkVision uses a pixel-based analysis approach to determine slot occupancy:

  1. Edge Detection - Applies Canny edge detection to identify car outlines
  2. Color Variance - Calculates standard deviation of pixel values
  3. 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 threshold

πŸŽ›οΈ Configuration

You 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

πŸ“Έ Screenshots

Interactive Map

Parking Detection

Slot Detection View 1

Slot Detection

Slot Detection View 2

Overview

πŸ› οΈ Tech Stack

  • OpenCV - Computer vision and image processing
  • NumPy - Numerical operations
  • FastAPI - REST API framework
  • Flask-SocketIO - Real-time WebSocket support (optional)

πŸš€ Future Enhancements

  • 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

πŸ‘₯ Contributors

MathewX470
Mathew Punnen Chandy
Vishak R
Vishak R
Johan Thomas Roby
Johan Thomas Roby
Ashish Jacob
Ashish Jacob

🀝 Contributing

Contributions are welcome! Feel free to:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors