Skip to main content

Multi-object trackers in Python

Easy to use implementation of various multi-object tracking algorithms.

DOI

YOLOv3 + CentroidTracker TF-MobileNetSSD + CentroidTracker
Cars with YOLO Cows with tf-SSD
Video source: link Video source: link

Available Multi Object Trackers

  • CentroidTracker
  • IOUTracker
  • CentroidKF_Tracker
  • SORT

Available OpenCV-based object detectors:

  • detector.TF_SSDMobileNetV2
  • detector.Caffe_SSDMobileNet
  • detector.YOLOv3

Installation

This package requires Python 3.10 or later.

Pip install for OpenCV (version 3.4.3 or later) is available here and can be done with the following command:

pip install motrackers

Additionally, you can install the package through GitHub instead:

git clone https://github.com/adipandas/multi-object-tracker
cd multi-object-tracker
pip install [-e] .

Note - for using neural network models with GPU
For using the opencv dnn-based object detection modules provided in this repository with GPU, you may have to compile a CUDA enabled version of OpenCV from source.

  • To build opencv from source, refer the following links: [link-1], [link-2]

How to use?: Examples

The interface for each tracker is simple and similar. Please refer the example template below.

from motrackers import CentroidTracker # or IOUTracker, CentroidKF_Tracker, SORT
input_data = ...
detector = ...
tracker = CentroidTracker(...) # or IOUTracker(...), CentroidKF_Tracker(...), SORT(...)
while True:
    done, image = <read(input_data)>
    if done:
        break
    detection_bboxes, detection_confidences, detection_class_ids = detector.detect(image)
    # NOTE: 
    # * `detection_bboxes` are numpy.ndarray of shape (n, 4) with each row containing (bb_left, bb_top, bb_width, bb_height)
    # * `detection_confidences` are numpy.ndarray of shape (n,);
    # * `detection_class_ids` are numpy.ndarray of shape (n,).
    output_tracks = tracker.update(detection_bboxes, detection_confidences, detection_class_ids)
    # `output_tracks` is a list with each element containing tuple of
    # (<frame>, <id>, <bb_left>, <bb_top>, <bb_width>, <bb_height>, <conf>, <x>, <y>, <z>)
    for track in output_tracks:
        frame, id, bb_left, bb_top, bb_width, bb_height, confidence, x, y, z = track
        assert len(track) == 10
        print(track)

Please refer examples folder of this repository for more details. You can clone and run the examples.

Running tests

Install the test dependencies and run the test suite with:

pip install -e ".[test]"
pytest

Pretrained object detection models

You will have to download the pretrained weights for the neural-network models. The shell scripts for downloading these are provided here below respective folders. Please refer DOWNLOAD_WEIGHTS.md for more details.

Notes

  • There are some variations in implementations as compared to what appeared in papers of SORT and IoU Tracker.
  • In case you find any bugs in the algorithm, I will be happy to accept your pull request or you can create an issue to point it out.

References, Credits and Contributions

Please see REFERENCES.md and CONTRIBUTING.md.

Citation

If you use this repository in your work, please consider citing it with:

@misc{multiobjtracker_amd2018,
  author = {Deshpande, Aditya M.},
  title = {Multi-object trackers in Python},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/adipandas/multi-object-tracker}},
}

Metadata

Release files for motrackers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for motrackers 0.1.0
File Size Uploaded
motrackers-0.1.0.tar.gz 23.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for motrackers 0.1.0
File Interpreter ABI Platform
motrackers-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.3 kB

Release files / motrackers-0.1.0.tar.gz

Download URL motrackers-0.1.0.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b35e8edc1eec73555dee0b8ed46b42ce166a68bb35b742f1d0371c4bd977b7ed
BLAKE2b-256 checksum
How to use checksums
895d79eb2ad03326ef4038ce40a9d726c3adfabbc148ccace7bb8369b4b5b5ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / motrackers-0.1.0-py3-none-any.whl

Download URL motrackers-0.1.0-py3-none-any.whl
Size 25.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9e7ab1f0acf2152571fb9bd960982c084a0897ce31e0aabd2bdc8089226f017
BLAKE2b-256 checksum
How to use checksums
099c701d38c2a6e785a8be4386357590d236cdbc2b96457731f9f5f8f7713061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page