This project implements a real-time customer tracking system using computer vision to monitor how long customers spend in a store. It combines YOLO v11m for person detection with BoT-SORT tracking to maintain consistent customer IDs and measure their duration of stay.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/customer-time-tracking.git cd customer-time-tracking
-
Install dependencies:
pip install -r requirements.txt
- Create a
config.yaml
file with your camera settings - Adjust detection parameters in
settings.py
- Place your video files in the
streams/
directory
-
For live camera feed:
python time_notebook.py --source 0
-
For video file:
python time_notebook.py --source streams/your_video.mp4
- YOLO v11m: Used for person detection
- BoT-SORT: Deep learning-based tracking algorithm
- OpenCV: For video processing and visualization
- CUDA: GPU acceleration support
- Real-time person detection
- Persistent ID tracking across frames
- Time measurement for each detected person
- Visual display of tracking information
- Video output capability
-
Initialization
- Sets up YOLO model with CUDA support if available
- Initializes BoT-SORT tracker
- Opens video source
-
Main Processing Loop
- Reads video frames
- Performs person detection using YOLO
- Updates tracker with detection results
- Maintains time dictionary for each tracked ID
- Displays bounding boxes with IDs and time information
-
Time Tracking
if track_id not in tracker_time: tracker_time[track_id] = [perf_counter(), perf_counter()] tracker_time[track_id][1] = perf_counter()
- Python 3.x
- OpenCV
- Ultralytics YOLO
- CUDA-capable GPU (recommended)
- Deep SORT implementation
- Required Python packages:
- opencv-python
- ultralytics
- torch
- numpy
- easydict
- Ensure all dependencies are installed
- Place your input video in the streams directory
- Run the script:
python time_notebook.py
- Real-time visualization with:
- Bounding boxes around detected persons
- Tracking IDs
- Time duration for each person
- Option to save processed video
- Requires good lighting conditions
- Performance depends on GPU capability
- May lose tracking in crowded scenes
- Add multiple camera support
- Implement zone-based analytics
- Add customer flow patterns analysis
- Export tracking data to database