A real-time smart parking platform that combines computer vision and event-driven data engineering to monitor parking space availability. The system uses a YOLOv8-based object detection pipeline to analyze camera images, streams occupancy events through Apache Kafka, stores them in MongoDB, and serves live availability data via a Flask web dashboard that auto-refreshes every 5 seconds.
Camera Images
│
▼
[YOLOv8 Model] ──── occupancy detection
│
▼
[Kafka Producer] ──── streams events to topics
│
├──── IoT sensor topic ──► [Consumer] ──► MongoDB (parking_data)
│
└──── Image topic ──► [Consumer] ──► MongoDB (image_stats)
│
▼
[Flask Dashboard]
(auto-refresh every 5s)
- YOLOv8 computer vision — detects occupied/free parking spaces from images using a fine-tuned YOLO model (
best.pt) - Apache Kafka streaming — event-driven architecture with separate producer/consumer pairs for IoT sensor data and image analysis
- MongoDB storage — persists occupancy events with timestamps for both sensor and vision pipelines
- Flask web dashboard — displays real-time available spaces from both data sources, with automatic 5-second refresh
- Docker Compose — full containerized deployment of Kafka and MongoDB
| Component | Technology |
|---|---|
| Object Detection | YOLOv8 (Ultralytics), ONNX |
| Message Streaming | Apache Kafka |
| Database | MongoDB |
| Web Framework | Flask |
| Containerization | Docker Compose |
| Language | Python 3.7+ |
car_parking/
├── app.py # Flask web server and dashboard
├── producer.py # Kafka producer for IoT sensor data
├── producer_images.py # Kafka producer for camera images
├── consumer.py # Kafka consumer → MongoDB (parking_data)
├── consumer_image.py # Kafka consumer → MongoDB (image_stats)
├── image_to_data.py # Image preprocessing pipeline
├── kafka_to_mongo.py # Kafka–MongoDB bridge utilities
├── ml_model.py # YOLOv8 inference wrapper
├── test.py # Testing utilities
├── best.pt # YOLOv8 fine-tuned model weights
├── best.onnx # ONNX export of the model
├── docker-compose.yml # Kafka + MongoDB containers
├── Templates/ # Flask HTML templates
└── images/ # Sample parking lot images
- Python 3.7+
- Docker and Docker Compose
git clone https://github.com/karanehzm/car_parking.git
cd car_parkingpip install flask pymongo kafka-python ultralytics opencv-pythondocker-compose up --build -d# Start IoT data producer
python3 producer.py
# Start image producer
python3 producer_images.py
# Start IoT data consumer
python3 consumer.py
# Start image consumer
python3 consumer_image.py
# Start Flask web server
python3 app.pyNavigate to http://localhost:5000
Karaneh Zolfaghari Moghaddam
github.com/karanehzm
