Skip to content

API Reference#

The Norfair API is split into a handful of focused modules. Most tracking pipelines only touch a few of them: you wrap your detector's output in Detections, feed them to a Tracker, and optionally draw the results on top of the original frames.

Modules#

Module Purpose
Tracker Tracker, Detection, TrackedObject — the core online tracker.
Distances Built-in and custom distance functions used to match detections to tracks.
Filter Kalman filter factories that smooth the estimated state of each track.
Drawing Helpers to draw detections, tracked objects, paths, and grids on frames.
Video Optional helper for reading video files / camera feeds and writing output.
Camera Motion MotionEstimator and coordinate transformations for moving-camera scenarios.
Metrics MOT Challenge accumulators and file parsers for evaluation.
Utils Small utilities (get_cutout, print_objects_as_table).

Tracking in 5 lines#

The smallest useful pipeline only needs Tracker, Detection, and — optionally — draw_points to visualize the result:

1
2
3
4
5
6
7
8
9
from norfair import Detection, Tracker, Video, draw_points

tracker = Tracker(distance_function="euclidean", distance_threshold=50)
with Video(input_path="video.mp4") as video:
    for frame in video:
        detections = [Detection(points) for points in my_detector(frame)]
        tracked_objects = tracker.update(detections=detections)
        draw_points(frame, tracked_objects)
        video.write(frame)

For an end-to-end walkthrough (installation, detector integration, debugging tips) see Getting Started.