Trajectory Forecast is a lightweight, modular extension built on top of Ultralytics YOLO that enables real-time multi-object tracking with future motion prediction. It combines detection, tracking, motion history modeling, and velocity-based forecasting into a unified pipeline that can be used both as a command-line tool and as a Python library. The system is designed for practical computer vision applications such as traffic analytics, surveillance systems, robotics pipelines, and edge AI deployments. Unlike heavy deep-learning forecasting architectures, this framework uses a lightweight motion model optimized for stability and speed, making it suitable for:
- Autonomous systems
- Intelligent surveillance
- Traffic analytics
- Robotics perception pipelines
- Edge AI deployments
trajectory-forecasting-demo-github.mp4
The demo shows real-time object tracking with projected future trajectories, where predicted points indicate the expected motion path.
Designed for low-latency environments such as robotics and surveillance.
Supports advanced trackers including:
- ByteTrack
- BoT-SORT
Predicts future object trajectories using velocity-based projection.
The framework is structured as reusable modules that can be integrated into larger vision systems.
Use as:
- Command-line application
- Python library
Video Input
│
▼
YOLO Object Detection
│
▼
Multi-Object Tracker
(ByteTrack / BoT-SORT)
│
▼
Trajectory History Buffer
│
▼
Velocity Estimation
│
▼
Trajectory Forecast Module
│
▼
Future Motion Visualization
Clone the repository:
git clone https://github.com/arafathosense/trajectory-forecast.git
cd trajectory-forecastInstall dependencies:
pip install -r requirements.txtRecommended environment:
Python ≥ 3.10
CUDA-enabled GPU (optional)
Create a configuration file named config.yaml.
conf: 0.5
tracker: "bytetrack.yaml"
classes: [2, 3, 5]
history: 40
min_points: 8
forecast_steps: 35
vel_window: 10
ema_alpha: 0.7
forecast_color: [255, 0, 0]| Parameter | Description |
|---|---|
| conf | Detection confidence threshold |
| tracker | Tracker configuration file |
| history | Number of frames used for trajectory history |
| forecast_steps | Number of future trajectory points |
| vel_window | Frames used for velocity estimation |
| ema_alpha | Smoothing coefficient |
trajectory-forecast \
--model yolo26n.pt \
--source "https://tinyurl.com/bddswzba" \
--config "path/to/config.yaml"Supported input sources:
- Webcam streams
- Video files
- Network streams
- Image sequences
The framework can be embedded into Python pipelines.
from tf import run_inference
from tf.config import ForecastConfig
config = ForecastConfig(
conf=0.5,
forecast_steps=50,
ema_alpha=0.7,
classes=[0, 2, 5, 6, 7]
)
run_inference(
model="yolo26n.pt",
source="video.mp4",
config=config
)The trajectory forecasting module is based on lightweight motion modeling.
Pipeline components include:
Bounding box centers are extracted from tracked objects.
Noise reduction using trajectory smoothing.
Velocity is estimated using median displacement over recent frames.
Future positions are predicted using velocity extrapolation.
Objects with near-zero movement are filtered to prevent unstable predictions.
This design provides stable real-time trajectory prediction without requiring computationally expensive deep neural networks.
Trajectory prediction is useful in many AI domains:
| Application | Example |
|---|---|
| Autonomous Driving | Vehicle path prediction |
| Traffic Monitoring | Flow analysis |
| Robotics | Motion planning |
| Security Systems | Suspicious movement detection |
| Smart Cities | Crowd analytics |
Example benchmark (RTX GPU):
| Model | FPS | Forecast Steps |
|---|---|---|
| YOLO-Nano | ~120 FPS | 30 |
| YOLO-Small | ~85 FPS | 35 |
| YOLO-Medium | ~55 FPS | 40 |
Actual performance depends on GPU, video resolution, and tracker configuration.
This project builds upon the open-source computer vision ecosystem developed by:
- Ultralytics for YOLO detection models
- Open-source multi-object tracking research community
Contributions are welcome.
You can contribute by:
- Improving trajectory prediction algorithms
- Adding new trackers
- Improving performance optimization
- Enhancing documentation
Please open an issue or submit a pull request.
Released under the MIT License.
HOSEN ARAFAT
Software Engineer, China
GitHub: https://github.com/arafathosense
Researcher: Artificial Intelligence, Image Computing, Image Processing, Machine Learning, Deep Learning, Computer Vision