# flyfocusuav/norfair architecture

> Architecture diagram of the GitHub repository flyfocusuav/norfair, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flyfocusuav/norfair
- Repository: https://github.com/flyfocusuav/norfair

## Overview

Norfair is a lightweight Python library for real-time multi-object tracking. Its main workflow accepts detector-produced point detections, associates them across frames, and returns tracked objects; optional video helpers support frame input/output. Distance functions, Kalman filters, and camera-motion transformations provide internal tracking mechanisms, while drawing and metrics support downstream use. The README also documents detector integrations, re-identification, 3D tracking, and other advanced demos. Some of those integrations are documented but their implementation was not sampled, so their links are shown only where the README supports them.

Main entry points: [`norfair/tracker.py`](https://github.com/flyfocusuav/norfair/blob/master/norfair/tracker.py) (Tracker), [`norfair/video.py`](https://github.com/flyfocusuav/norfair/blob/master/norfair/video.py) (Video Helpers), [`norfair/drawing/drawer.py`](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/drawer.py) (Drawing Primitives), [`norfair/drawing/color.py`](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/color.py) (Color Palette)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tracking["Tracking Core"]
  node_tracker["Tracker<br/>[tracker.py]"]
  node_utils["Shared Utilities<br/>[utils.py]"]
end

subgraph group_motion["Motion And Matching"]
  node_filter["State Filters<br/>[filter.py]"]
  node_distances["Distance Functions<br/>[distances.py]"]
  node_camera_motion["Camera Motion<br/>[camera_motion.py]"]
end

subgraph group_rendering["Visualization"]
  node_box_drawing["Box Drawing<br/>[draw_boxes.py]"]
  node_point_drawing["Point Drawing<br/>[draw_points.py]"]
  node_drawer["Drawing Primitives<br/>[drawer.py]"]
  node_colors["Color Palette<br/>[color.py]"]
  node_paths["Track Paths<br/>[path.py]"]
  node_fixed_camera["Fixed Camera View<br/>[fixed_camera.py]"]
  node_absolute_grid["Absolute Grid<br/>[absolute_grid.py]"]
end

subgraph group_io_eval["Video And Evaluation"]
  node_video["Video Helpers<br/>[video.py]"]
  node_metrics["Tracking Metrics<br/>[metrics.py]"]
end

node_detector(("Object Detector"))
node_video_source(("Video Source"))
node_video_output(("Annotated Video"))
node_ros["ROS Integration"]

node_video_source -.->|"provides frames"| node_video
node_detector -->|"supplies detections"| node_tracker
node_tracker -->|"uses matching"| node_distances
node_tracker -->|"creates filters"| node_filter
node_tracker -->|"uses transformations"| node_camera_motion
node_tracker -->|"validates points"| node_utils
node_tracker -.->|"returns tracks"| node_box_drawing
node_tracker -.->|"returns tracks"| node_point_drawing
node_video -->|"uses helpers"| node_utils
node_video -.->|"supports evaluation"| node_metrics
node_box_drawing -->|"draws with"| node_drawer
node_box_drawing -->|"selects colors"| node_colors
node_point_drawing -->|"draws with"| node_drawer
node_point_drawing -->|"selects colors"| node_colors
node_paths -->|"draws with"| node_drawer
node_paths -->|"selects colors"| node_colors
node_fixed_camera -->|"uses transformations"| node_camera_motion
node_absolute_grid -->|"uses transformations"| node_camera_motion
node_absolute_grid -->|"draws with"| node_drawer
node_absolute_grid -->|"selects colors"| node_colors
node_video -.->|"writes frames"| node_video_output
node_metrics -->|"uses helpers"| node_utils
node_ros -.->|"integrates with"| node_tracker

click node_tracker "https://github.com/flyfocusuav/norfair/blob/master/norfair/tracker.py"
click node_filter "https://github.com/flyfocusuav/norfair/blob/master/norfair/filter.py"
click node_distances "https://github.com/flyfocusuav/norfair/blob/master/norfair/distances.py"
click node_camera_motion "https://github.com/flyfocusuav/norfair/blob/master/norfair/camera_motion.py"
click node_utils "https://github.com/flyfocusuav/norfair/blob/master/norfair/utils.py"
click node_video "https://github.com/flyfocusuav/norfair/blob/master/norfair/video.py"
click node_metrics "https://github.com/flyfocusuav/norfair/blob/master/norfair/metrics.py"
click node_box_drawing "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/draw_boxes.py"
click node_point_drawing "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/draw_points.py"
click node_drawer "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/drawer.py"
click node_colors "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/color.py"
click node_paths "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/path.py"
click node_fixed_camera "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/fixed_camera.py"
click node_absolute_grid "https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/absolute_grid.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tracker,node_utils toneBlue
class node_filter,node_distances,node_camera_motion toneAmber
class node_box_drawing,node_point_drawing,node_drawer,node_colors,node_paths,node_fixed_camera,node_absolute_grid toneMint
class node_video,node_metrics toneRose
class node_detector,node_video_source,node_video_output,node_ros toneIndigo
```

## Components

### Tracking Core

- [Tracker](https://github.com/flyfocusuav/norfair/blob/master/norfair/tracker.py): `norfair/tracker.py`
- [Shared Utilities](https://github.com/flyfocusuav/norfair/blob/master/norfair/utils.py): `norfair/utils.py`

### Motion And Matching

- [State Filters](https://github.com/flyfocusuav/norfair/blob/master/norfair/filter.py): `norfair/filter.py`
- [Distance Functions](https://github.com/flyfocusuav/norfair/blob/master/norfair/distances.py): `norfair/distances.py`
- [Camera Motion](https://github.com/flyfocusuav/norfair/blob/master/norfair/camera_motion.py): `norfair/camera_motion.py`

### Visualization

- [Box Drawing](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/draw_boxes.py): `norfair/drawing/draw_boxes.py`
- [Point Drawing](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/draw_points.py): `norfair/drawing/draw_points.py`
- [Drawing Primitives](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/drawer.py): `norfair/drawing/drawer.py`
- [Color Palette](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/color.py): `norfair/drawing/color.py`
- [Track Paths](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/path.py): `norfair/drawing/path.py`
- [Fixed Camera View](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/fixed_camera.py): `norfair/drawing/fixed_camera.py`
- [Absolute Grid](https://github.com/flyfocusuav/norfair/blob/master/norfair/drawing/absolute_grid.py): `norfair/drawing/absolute_grid.py`

### Video And Evaluation

- [Video Helpers](https://github.com/flyfocusuav/norfair/blob/master/norfair/video.py): `norfair/video.py`
- [Tracking Metrics](https://github.com/flyfocusuav/norfair/blob/master/norfair/metrics.py): `norfair/metrics.py`

### Other components

- **Object Detector**
- **Video Source**
- **Annotated Video**
- **ROS Integration**

## Connections

- Video Source → Video Helpers: provides frames (evidence: `README.md`)
- Object Detector → Tracker: supplies detections (evidence: `README.md`)
- Tracker → Distance Functions: uses matching (evidence: `norfair/tracker.py`)
- Tracker → State Filters: creates filters (evidence: `norfair/tracker.py`)
- Tracker → Camera Motion: uses transformations (evidence: `norfair/tracker.py`)
- Tracker → Shared Utilities: validates points (evidence: `norfair/tracker.py`)
- Tracker → Box Drawing: returns tracks (evidence: `README.md`)
- Tracker → Point Drawing: returns tracks (evidence: `README.md`)
- Video Helpers → Shared Utilities: uses helpers (evidence: `norfair/video.py`)
- Video Helpers → Tracking Metrics: supports evaluation (evidence: `README.md`)
- Box Drawing → Drawing Primitives: draws with (evidence: `norfair/drawing/draw_boxes.py`)
- Box Drawing → Color Palette: selects colors (evidence: `norfair/drawing/draw_boxes.py`)
- Point Drawing → Drawing Primitives: draws with (evidence: `norfair/drawing/draw_points.py`)
- Point Drawing → Color Palette: selects colors (evidence: `norfair/drawing/draw_points.py`)
- Track Paths → Drawing Primitives: draws with (evidence: `norfair/drawing/path.py`)
- Track Paths → Color Palette: selects colors (evidence: `norfair/drawing/path.py`)
- Fixed Camera View → Camera Motion: uses transformations (evidence: `norfair/drawing/fixed_camera.py`)
- Absolute Grid → Camera Motion: uses transformations (evidence: `norfair/drawing/absolute_grid.py`)
- Absolute Grid → Drawing Primitives: draws with (evidence: `norfair/drawing/absolute_grid.py`)
- Absolute Grid → Color Palette: selects colors (evidence: `norfair/drawing/absolute_grid.py`)
- Video Helpers → Annotated Video: writes frames (evidence: `README.md`)
- Tracking Metrics → Shared Utilities: uses helpers (evidence: `norfair/metrics.py`)
- ROS Integration → Tracker: integrates with (evidence: `README.md`)
