Skip to main content

Toolkit for object tracking in computer vision applications.

Project description

Unified Tracking in PyTorch

This package is a robust object tracking framework for PyTorch. t facilitates multi-stage and cascaded tracking algorithms under various modular configurations and assignment algorithms. This open-source implementation is designed to facilitate research in computer vision and machine learning.

Installation

Ensure your environment meets the following requirements:

  • python >= 3.11
  • torch >= 2.2

Install via PyPI using the following command:

pip install unitrack

Usage

The following example demonstrates object tracking across a sequence with detections that have category and position fields. This script tracks objects, updates internal state buffers for each frame, and prints the assigned IDs.

import unitrack

# Detections from 10 video frames having fields `category` and `position`.
frames = [
    {
        "category": torch.ones(1 + frame * 2, dtype=torch.long),
        "position": (torch.arange(1 + frame * 2, dtype=dtype)).unsqueeze(1),
    }
    for frame in range(0, 10)
]

# Multi-stage tracker with two value fields that map the detections' data
# to keys `pos_key` and `key_cat`, where the association stage calculates 
# the Euclidean distance of the positions between frames and subsequently 
# performs a Jonker-Volgenant assignment using the resulting cost matrix
tracker = unitrack.MultiStageTracker(
    fields={
        "key_pos": unitrack.fields.Value(key="category"),
        "key_cat": unitrack.fields.Value(key="position"),
    },
    stages=[unitrack.stages.Association(cost=costs.Distance("key_pos"), assignment=unitrack.assignment.Jonker(10))],
)

# Tracking memory that stores the relevant information to compute the
# cost matrix in the module buffers. States are observed at each frame,
# where in this case no state prediction is performed.
memory = unitrack.TrackletMemory(
    states={
        "key_pos": unitrack.states.Value(dtype),
        "key_cat": unitrack.states.Value(dtype=torch.long),
    }
)

# Iterate over frames, performing state observation, tracking and state
# propagation at every step.
for frame, detections in enumerate(frames):
    # Create a context object storing (meta)data about the current
    # frame, i.e. feature maps, instance detections and the frame number.
    ctx = unitrack.Context(None, detections, frame=frame)
    
    # Observe the states in memory. This can be extended to 
    # run a prediction step (e.g. Kalman filter) 
    obs = memory.observe()
    
    # Assign detections in the current frame to observations of
    # the state memory, giving an updated observations object
    # and the remaining unassigned new detections.
    obs, new = tracker(ctx, obs)
    
    # Update the tracking memory. Buffers are updated to match
    # the data in `obs`, and new IDs are generated for detection
    # data that could not be assigned in `new`. The returned tensor
    # contains ordered tracklet IDs for the detections assigned
    # to the frame context `ctx`.
    ids = tracks.update(ctx, obs, new)

    print(f"Assigned tracklet IDs {ids.tolist()} @ frame {frame}")

Citation

If you use this package in your research, please cite our paper as

@inproceedings{stolle2023unitrack,
    title={Unified Perception: Efficient Depth-Aware Video Panoptic Segmentation with Minimal Annotation Costs},
    author={Kurt Stolle and Gijs Dubbelman},
    booktitle={IROS},
    year={2023}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitrack-1.0.0.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unitrack-1.0.0-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file unitrack-1.0.0.tar.gz.

File metadata

  • Download URL: unitrack-1.0.0.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for unitrack-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8deae7b8ac2bd9a859265783d6b47bf024f7d50d59b180b41fe3d3bb3dab8fac
MD5 d0eafb84d0193037d5b5a32c9eb8056e
BLAKE2b-256 d7071c9e9f643582991dbd459b61766afe4ac8d58e67490c75bcb711f14b2104

See more details on using hashes here.

File details

Details for the file unitrack-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: unitrack-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for unitrack-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 669a2ac4e70ec94743f8a9ecdb72e4139ec7e4a96fb94fbf930a7835e7543fb0
MD5 749f389f37aaa0a39c90b15c718de147
BLAKE2b-256 6547f9041774732e17e8093ff9e1d53efa9177378b8c17a460bbbaeb0d3ba6df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page