Master's Thesis (TFM) project: a real-time system for counting and tracking people inside pharmacies using deep learning. It detects customers with YOLO, tracks them with DeepSORT, analyzes dwell time per zone, and generates heatmaps — all with built-in GDPR-compliant privacy (real-time pixelation, local processing only).
|
Detection & Counting
|
Tracking & Analytics
|
|
Privacy & Compliance
|
User Interface
|
| Control panel | Processing & real-time controls |
| Virtual counting lines | Polygonal zone definition |
| Real-time people counting | Privacy pixelation enabled |
| DeepSORT trajectory tracking | Generated heatmap |
graph TD
A[GUI - CustomTkinter] -->|Tools Tab| B[Configuration]
B --> B1[Define Virtual Lines]
B --> B2[Define Polygonal Zones]
A -->|Processing Tab| C[Detection & Analysis]
C --> C1[YOLOv5 Counting]
C --> C2[YOLOv8 + DeepSORT Tracking]
C1 --> D[Export]
C2 --> D
D --> D1[datos_conteo/ JSON]
D --> D2[datos_tracking/ JSON]
D --> D3[heatmaps/ PNG]
- Python 3.8+
- pip
git clone https://github.com/patatapython/Sistema-Tracking-Farmacia.git
cd Sistema-Tracking-Farmacia
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
pip install -r requirements.txt# YOLOv5s (~15MB)
wget https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s.pt
# YOLOv8s (~22MB)
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.ptpython uiFarmacia_logo.py- Configure (Tools tab): define counting lines and polygonal zones interactively
- Process (Processing tab): select video source, start counting or tracking
- Analyze: results are automatically exported to
datos_conteo/,datos_tracking/, andheatmaps/
Output data formats
Counting (datos_conteo/*.json):
{
"entradas": 15,
"salidas": 12,
"total_personas": 27,
"personas_dentro": 3,
"timestamp": "2025-09-05T14:42:45.598Z"
}Tracking (datos_tracking/*.json):
{
"timestamp": "20250905_144534",
"total_personas": 5,
"sistema_tracking": "DeepSORT",
"personas": [
{
"id": 1,
"zona_actual": "mostrador",
"tiempo_en_zona_actual": 45.2,
"historial_zonas": [
{
"zona": "entrada",
"tiempo_entrada": "2025-09-05T14:40:00",
"tiempo_salida": "2025-09-05T14:40:30",
"duracion": 30.0
}
]
}
]
}Sistema-Tracking-Farmacia/
├── uiFarmacia_logo.py Main GUI application
├── conteo.py YOLOv5 people counting module
├── tracking.py YOLOv8 + DeepSORT tracking module
├── crear_linea.py Interactive counting line creator
├── crear_zonas.py Interactive polygonal zone creator
├── config/ Line and zone configuration files
├── datos_conteo/ Counting results (JSON)
├── datos_tracking/ Tracking results (JSON)
├── heatmaps/ Generated heatmap images (PNG)
├── extras/Imagenes/ Screenshots for documentation
├── Logo/ Application logo
└── requirements.txt Python dependencies
Developed as a Master's Thesis (TFM) by Guillermo — patatapython
Special thanks to:
- Ultralytics for YOLO models
- OpenCV for computer vision tools
Distributed under the MIT License. See LICENSE for details.