BoxMOT: Your Go-To for Advanced Object Tracking

22/11/2015

Rating: 4.98 (16464 votes)

In the rapidly evolving world of computer vision, accurately tracking multiple objects across video streams is a formidable challenge. Whether you're dealing with identifying pedestrians in busy cityscapes or monitoring equipment on a factory floor, the ability to maintain a consistent identity for each object over time is crucial. This is precisely where Multi-Object Tracking (MOT) comes into play, and it’s a field that’s seen significant advancements. However, integrating state-of-the-art tracking solutions can often be a complex and resource-intensive endeavour, leading to frustrating delays and compatibility headaches for developers and researchers alike. Fortunately, a powerful solution has emerged to streamline this process: BoxMOT.

What is boxmot & morover?
BoxMOT provides a great variety of tracking methods that meet different hardware limitations, all the way from CPU only to larger GPUs. Morover, we provide scripts for ultra fast experimentation by saving detections and embeddings, which then be loaded into any tracking algorithm. Avoiding the overhead of repeatedly generating this data.

BoxMOT is not just another piece of software; it’s a comprehensive, pluggable collection of cutting-edge multi-object trackers designed to work seamlessly with various computer vision models. It simplifies the integration of advanced tracking capabilities into your projects, supporting everything from object detection to segmentation and even pose estimation. This means that whether your model is looking for bounding boxes, pixel-level masks, or human skeletal structures, BoxMOT can help you track them effectively and efficiently. It’s built with flexibility in mind, offering a variety of tracking methods that cater to different computational requirements, from lightweight solutions suitable for CPUs to more demanding algorithms that leverage the power of larger GPUs. This adaptability is one of its core strengths, making it accessible to a wide range of users and hardware setups.

Table

What Exactly is BoxMOT?

At its heart, BoxMOT is a repository and a Python package that brings together some of the most advanced multi-object tracking algorithms available today. It’s designed to be 'pluggable,' which means you can easily integrate its tracking modules into your existing computer vision pipelines. Think of it like a toolbox filled with specialised instruments; you pick the right tool for the job without having to build it from scratch every time. This modular approach is a significant time-saver and allows for rapid experimentation and deployment.

The library supports various types of visual data, including:

  • Object Detection: Identifying and localising objects within an image or video frame with bounding boxes.
  • Segmentation: Pinpointing objects at a pixel level, providing more precise boundaries than simple bounding boxes.
  • Pose Estimation: Detecting the position and orientation of key points on an object, typically used for human body tracking.

One of the standout features of BoxMOT is its robust support for ReID (Re-Identification) models. ReID is critical for robust tracking, as it helps maintain an object's identity even when it's temporarily obscured or moves out of frame. BoxMOT offers a selection of both heavy and lightweight state-of-the-art ReID models, such as CLIPReID for more demanding scenarios and LightMBN, OSNet, and others for more resource-constrained environments. These models are available for automatic download, further simplifying the setup process.

Furthermore, BoxMOT provides excellent compatibility with popular object detection models, including the widely used YOLO series (YOLOv8, YOLOv9, and YOLOv10). This means if you're already working with these models for your detection tasks, integrating BoxMOT for tracking becomes a straightforward affair, allowing you to quickly add advanced MOT capabilities without extensive re-engineering.

Why Choose BoxMOT? The 'Morover' Factor

The question of 'Why BoxMOT?' is easily answered by understanding its core advantages, which address some of the most common pain points in multi-object tracking:

Hardware Independence and Versatility

Today's multi-object tracking solutions often demand specific, high-end hardware, limiting their accessibility. BoxMOT breaks down this barrier by offering a diverse range of tracking methods that are adaptable to different computational capabilities. Whether you're working with a basic CPU-only setup or have access to powerful GPUs, BoxMOT has a tracking algorithm that can meet your needs. This flexibility ensures that advanced tracking isn't solely reserved for those with top-tier equipment.

Ultra-Fast Experimentation

One of the most time-consuming aspects of developing and fine-tuning tracking systems is the repeated generation of detection and embedding data. This overhead can significantly slow down the experimentation process. BoxMOT cleverly addresses this by providing scripts that allow you to save these detections and embeddings. Once saved, this data can be loaded into any tracking algorithm within BoxMOT, eliminating the need to re-generate it every time you test a new configuration or tracker. This capability dramatically accelerates the iteration cycle, enabling faster development and optimization.

State-of-the-Art Performance

BoxMOT isn't just about convenience; it's also about performance. The collection includes high-performing trackers that consistently achieve impressive results on standard benchmarks. For instance, consider the performance on the MOT17 dataset, using ByteTrack's YoloXm detector:

TrackerHOTA↑MOTA↑IDF1↑
BoTSORT77.878.988.9
DeepOCSORT77.478.489.0
OCSORT77.478.489.0
HybridSORT77.377.988.8
ByteTrack75.674.686.0
StrongSORT ImprAssoc(Data not provided for this specific row, but expected to be competitive)

NOTES: These results were performed on the first 10 frames of each MOT17 sequence. The detector used is ByteTrack's YoloXm, trained on CrowdHuman, MOT17, Cityperson, and ETHZ. Each tracker is configured with its original parameters found in their respective official repository.

These metrics (HOTA, MOTA, IDF1) are standard in the MOT community for evaluating tracker performance, reflecting various aspects like association quality, detection accuracy, and identity preservation. The table clearly shows that BoxMOT integrates trackers that are at the forefront of the field.

Getting Started with BoxMOT: Installation and Usage

Setting up BoxMOT is designed to be straightforward, allowing you to quickly dive into experimenting with its capabilities. You'll need Python 3.9 or newer to get started.

Installation

If you plan to run the examples that integrate with YOLOv8, YOLOv9, or YOLOv10, the recommended installation method involves cloning the repository:

git clone https://github.com/mikel-brostrom/boxmot.git cd boxmot pip install poetry poetry install --with yolo # Installs BoxMOT + YOLO dependencies poetry shell # Activates the newly created environment 

However, if your goal is simply to import the tracking modules into an existing project without needing the full YOLO example setup, you can opt for a simpler installation:

pip install boxmot 

Basic Tracking Examples (YOLO Models)

Once installed, using BoxMOT with YOLO models is quite intuitive. You can specify the YOLO model and the type of output you want (bounding boxes, segmentation masks, or pose estimation):

python tracking/track.py --yolo-model yolov10n # Bounding boxes only python tracking/track.py --yolo-model yolov9s # Bounding boxes only python tracking/track.py --yolo-model yolov8n # Bounding boxes only python tracking/track.py --yolo-model yolov8n-seg # Bounding boxes + segmentation masks python tracking/track.py --yolo-model yolov8n-pose # Bounding boxes + pose estimation 

Selecting Tracking Methods

BoxMOT allows you to easily switch between different tracking algorithms to find the best fit for your application or to compare their performance:

python tracking/track.py --tracking-method deepocsort strongsort ocsort bytetrack botsort imprassoc 

Tracking Sources

The system is highly flexible regarding input sources, supporting a wide array of video formats and live feeds:

python tracking/track.py --source 0 # Webcam python tracking/track.py --source img.jpg # Image file python tracking/track.py --source vid.mp4 # Video file python tracking/track.py --source path/ # Directory of images python tracking/track.py --source 'path/*.jpg' # Glob pattern for images python tracking/track.py --source 'https://youtu.be/Zgi9g1ksQHc' # YouTube URL python tracking/track.py --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream 

Choosing a ReID Model

For tracking methods that rely on appearance description, you can select a ReID model from BoxMOT’s integrated model zoo. This allows you to balance performance with computational requirements:

python tracking/track.py --source 0 --reid-model lmbn_n_cuhk03_d.pt # Lightweight model python tracking/track.py --source 0 --reid-model osnet_x0_25_market1501.pt python tracking/track.py --source 0 --reid-model clip_market1501.pt # Heavy model 

Filtering Tracked Classes

By default, BoxMOT tracks all MS COCO classes. However, you can specify a subset of classes if your application only requires tracking specific object types:

python tracking/track.py --source 0 --yolo-model yolov8s.pt --classes 16 17 # Track only cats and dogs for a YOLOv8 COCO model 

It's important to note that class indexing in BoxMOT starts at zero, aligning with standard computer science practices.

Evaluation and Hyperparameter Tuning

BoxMOT isn't just about deploying trackers; it also provides robust tools for evaluating their performance and optimising their parameters. This is crucial for achieving the best possible results for your specific use case.

Performance Evaluation

You can evaluate a combination of detectors, tracking methods, and ReID models on standard MOT datasets (like MOT17) or your custom datasets:

python3 tracking/val.py --benchmark MOT17-mini --yolo-model yolov8n.pt --reid-model osnet_x0_25_msmt17.pt --tracking-method deepocsort --verbose --source ./assets/MOT17-mini/train 

A key feature here is that detections and embeddings are stored separately for the selected YOLO and ReID models. This means you can load this pre-generated data into any tracking algorithm, again avoiding the computational overhead of recalculating it every time you run an evaluation.

Automated Hyperparameter Evolution

Achieving optimal tracker performance often requires meticulous tuning of numerous hyperparameters. BoxMOT simplifies this complex task using a fast and elitist multiobjective genetic algorithm. By default, it optimises for HOTA, MOTA, and IDF1 – key metrics for tracking performance.

What is boxmot & morover?
BoxMOT provides a great variety of tracking methods that meet different hardware limitations, all the way from CPU only to larger GPUs. Morover, we provide scripts for ultra fast experimentation by saving detections and embeddings, which then be loaded into any tracking algorithm. Avoiding the overhead of repeatedly generating this data.

The process generally involves two steps:

  1. Generate Detections and Embeddings: This step pre-processes your data, saving the raw detections and ReID embeddings for specific YOLO and ReID models.
  2. python tracking/generate_dets_n_embs.py --source ./assets/MOT17-mini/train --yolo-model yolov8n.pt yolov8s.pt --reid-model weights/osnet_x0_25_msmt17.pt 
  3. Evolve Parameters: Once the data is prepared, you can run the evolution script to find the best hyperparameters for your chosen tracking method.
  4. python tracking/evolve.py --benchmark MOT17-mini --dets yolov8n --embs osnet_x0_25_msmt17 --n-trials 9 --tracking-method botsort 

The best performing set of hyperparameters (typically those leading to the highest HOTA score) are automatically written to the tracker's configuration file, making the optimisation process seamless and efficient.

Model Export and Custom Integration

ReID Model Export

For deployment in various environments or for further optimisation, BoxMOT supports exporting ReID models to several popular formats, including ONNX, OpenVINO, TorchScript, and TensorRT. This flexibility ensures that your trained models can be used across different platforms and hardware accelerators.

python3 boxmot/appearance/reid_export.py --include onnx --device cpu # Export to ONNX python3 boxmot/appearance/reid_export.py --include openvino --device cpu # Export to OpenVINO python3 boxmot/appearance/reid_export.py --include engine --device 0 --dynamic # Export to TensorRT with dynamic input 

Custom Tracking Examples

BoxMOT provides clear examples for custom integration, allowing developers to incorporate its tracking capabilities into their own applications. This includes examples for basic detection tracking, as well as more advanced scenarios involving pose estimation and segmentation masks, and even tiled inference for handling large images efficiently.

Detection Example Snippet

This snippet demonstrates how to integrate BoxMOT's DeepOCSORT tracker into a basic detection loop:

import cv2 import numpy as np from pathlib import Path from boxmot import DeepOCSORT tracker = DeepOCSORT( model_weights=Path('osnet_x0_25_msmt17.pt'), # ReID model device='cuda:0', fp16=False, ) vid = cv2.VideoCapture(0) while True: ret, im = vid.read() # Substitute with your object detector output (N x (x, y, x, y, conf, cls)) dets = np.array([[144, 212, 578, 480, 0.82, 0], [425, 281, 576, 472, 0.56, 65]]) if dets.size > 0: tracks = tracker.update(dets, im) # Returns M x (x, y, x, y, id, conf, cls, ind) else: tracks = tracker.update(np.empty((0, 6)), im) tracker.plot_results(im, show_trajectories=True) cv2.imshow('BoxMOT detection', im) key = cv2.waitKey(1) & 0xFF if key == ord(' ') or key == ord('q'): break vid.release() cv2.destroyAllWindows() 

Pose & Segmentation Example Snippet

For more complex outputs like keypoints or masks, BoxMOT can also handle the association:

import cv2 import numpy as np from pathlib import Path from boxmot import DeepOCSORT tracker = DeepOCSORT( model_weights=Path('osnet_x0_25_msmt17.pt'), device='cuda:0', fp16=True, ) vid = cv2.VideoCapture(0) while True: ret, im = vid.read() # Dummy keypoints and masks (replace with actual detector output) keypoints = np.random.rand(2, 17, 3) mask = np.random.rand(2, 480, 640) dets = np.array([[144, 212, 578, 480, 0.82, 0], [425, 281, 576, 472, 0.56, 65]]) tracks = tracker.update(dets, im) # Use 'ind' to associate tracks with corresponding masks/keypoints inds = tracks[:, 7].astype('int') # masks = masks[inds] # Example: how to link masks to tracks # keypoints = keypoints[inds] # Example: how to link keypoints to tracks cv2.imshow('BoxMOT segmentation | pose', im) key = cv2.waitKey(1) & 0xFF if key == ord(' ') or key == ord('q'): break vid.release() cv2.destroyAllWindows() 

Frequently Asked Questions (FAQs) about BoxMOT

Q1: What is Multi-Object Tracking (MOT) and why is it important?

A1: Multi-Object Tracking (MOT) is a computer vision task that involves identifying multiple objects in a video sequence and maintaining their unique identities over time. It's crucial for applications like autonomous driving, surveillance, sports analytics, and crowd monitoring, where understanding the movement and interactions of individual entities is vital.

Q2: What kind of models does BoxMOT support for object detection?

A2: BoxMOT provides direct support and examples for popular YOLO models, specifically YOLOv8, YOLOv9, and YOLOv10. Its pluggable nature also means it can potentially work with outputs from other object detectors, provided they conform to the expected input format (bounding boxes, confidence, class ID).

Q3: What are ReID models, and why are they used in BoxMOT?

A3: ReID (Re-Identification) models are deep learning models that generate unique "appearance descriptions" or embeddings for objects. They are used in tracking to help re-associate an object with its previous identity even if it disappears from view for a short period or changes its appearance slightly. BoxMOT offers both heavy (e.g., CLIPReID) and lightweight (e.g., LightMBN, OSNet) ReID models to suit various computational needs.

Q4: Can I use BoxMOT on a CPU, or do I need a powerful GPU?

A4: BoxMOT is designed with hardware versatility in mind. It provides various tracking methods, some of which are lightweight enough to run efficiently on CPUs, while others leverage the power of GPUs for higher performance. You can select the tracking method and ReID model that best suits your available hardware.

Q5: How does BoxMOT help with faster experimentation?

A5: BoxMOT allows you to save detections and embeddings generated by your YOLO and ReID models. Once saved, this data can be loaded and reused with different tracking algorithms without having to re-run the detection and embedding generation steps. This significantly reduces the time and computational resources needed for testing and fine-tuning.

Q6: What do HOTA, MOTA, and IDF1 metrics mean in the performance table?

A6: These are standard metrics for evaluating multi-object tracking performance:

  • HOTA (Higher Order Tracking Accuracy): A comprehensive metric that balances detection accuracy, association quality, and consistency. It’s considered a more holistic measure than older metrics.
  • MOTA (Multi-Object Tracking Accuracy): Primarily focuses on detection errors (false positives, false negatives, ID switches). It's a widely used metric but doesn't explicitly penalise identity switches as much as HOTA.
  • IDF1 (Identification F1 Score): Measures the ratio of correctly identified detections over the average of the number of ground truth and computed detections. It's good for evaluating how well identities are maintained.

Q7: Can I track specific object classes only, like just cars or pedestrians?

A7: Yes, BoxMOT allows you to filter the tracked classes. You can specify the class IDs (based on the MS COCO dataset, which starts indexing at zero) that your YOLO model detects, ensuring that the tracker only focuses on the objects of interest to your application.

Q8: How does BoxMOT help in optimising tracker parameters?

A8: BoxMOT includes an automated hyperparameter tuning feature using a multiobjective genetic algorithm (RayTune). This tool can automatically search for the optimal set of parameters for a given tracker, aiming to maximise metrics like HOTA, MOTA, and IDF1, thereby saving you significant manual effort.

Conclusion

BoxMOT stands out as an incredibly valuable tool for anyone working in the domain of computer vision, particularly with multi-object tracking. Its plug-and-play architecture, comprehensive support for state-of-the-art algorithms, and seamless integration with popular detection models like YOLO make it an indispensable asset. The ability to choose between lightweight and heavy ReID models, coupled with its hardware flexibility, ensures that advanced tracking capabilities are accessible to a broader audience. Moreover, the built-in tools for rapid experimentation, performance evaluation, and automated hyperparameter tuning significantly accelerate the development cycle, allowing researchers and developers to achieve optimal results with greater efficiency. Whether you're a seasoned computer vision engineer or just beginning to explore the world of object tracking, BoxMOT provides a robust, flexible, and high-performing foundation for your projects, ensuring you stay at the cutting edge of visual intelligence.

If you want to read more articles similar to BoxMOT: Your Go-To for Advanced Object Tracking, you can visit the Automotive category.

Go up