A comprehensive computer vision project that combines YOLO object detection with SORT (Simple Online and Realtime Tracking) algorithm to track people in videos and visualize their movement paths with elegant trail effects.
- Real-time person detection using YOLOv12 with high accuracy
- Multi-person tracking with SORT algorithm for consistent ID assignment
- Path visualization with customizable colors, thickness, and smooth transitions
- Fade effect option for more visually appealing trails
- Configurable tracking parameters for different scenarios
- Debug mode for quick testing and development
- Support for various video formats (mp4, avi, mov, etc.)
# Clone the repository
git clone https://github.com/yourusername/person-tracker.git
cd person-tracker
# Install dependencies
pip install -r requirements.txt
- Python 3.8+
- OpenCV 4.8+
- Ultralytics (YOLOv12)
- NumPy 1.24.0+
- SciPy 1.10.0+
- FilterPy 1.4.5 (for SORT algorithm)
- Additional libraries listed in requirements.txt
# Basic usage with default parameters
python Tracker.py
# Using custom video file
python Tracker.py --input your_video.mp4 --output result.mp4
# Customize tracking visual appearance
python Tracker.py --color blue --thickness 8 --fade-effect
# Adjust SORT tracking algorithm parameters
python Tracker.py --min-hits 5 --max-age 20 --iou-threshold 0.4
Option | Description | Default |
---|---|---|
--input |
Input video file path | Mossad.mp4 |
--output |
Output video file path | output_tracking.mp4 |
--debug |
Run in debug mode (process only 10 seconds) | False |
--thickness |
Path line thickness | 5 |
--color |
Path color (red, green, blue, yellow, etc.) | red |
--model |
YOLO model to use | yolo12n.pt |
--min-hits |
Minimum hits for SORT tracker | 3 |
--max-age |
Maximum age for SORT tracker (frames) | 30 |
--iou-threshold |
IOU threshold for SORT tracker | 0.3 |
--fade-effect |
Enable path fade effect | False |
The tracking system performs the following steps:
- Object Detection: Uses YOLOv12 to detect people in each video frame
- ID Assignment: Applies SORT algorithm to assign consistent IDs to detected people across frames
- Path Recording: Records the position (center point) of each person in each frame
- Path Smoothing: Applies interpolation for natural-looking paths
- Visualization: Renders the paths with customizable colors and optional fade effects
person-tracker/
βββ Tracker.py # Main tracking script with all functionality
βββ sort/ # SORT tracking algorithm implementation
β βββ sort.py # Core SORT algorithm
β βββ data/ # Training and test data for SORT
βββ requirements.txt # Dependencies list
βββ yolo12n.pt # YOLOv12 nano model weights
βββ README.md # Project documentation
For advanced users who want to fine-tune the tracking system:
- Modify the SORT parameters (
--min-hits
,--max-age
,--iou-threshold
) to balance between tracking stability and responsiveness - Try different YOLO models based on your performance requirements:
yolo12n.pt
(nano): Fastest but less accurateyolo12s.pt
(small): Balanced performanceyolo12m.pt
(medium): More accurate but sloweryolo12l.pt
(large): Most accurate, requires more computing power
- SORT - Simple Online and Realtime Tracking algorithm
- Ultralytics - YOLOv8 implementation
- OpenCV - Open Source Computer Vision Library
- Processing speed depends on your hardware, especially GPU availability
- For real-time tracking, consider using a smaller YOLO model or reducing input video resolution
- Tracking accuracy can be affected by occlusion, lighting conditions, and camera movement
Project Link: https://github.com/bigman1208000/person-tracker-sort