Run local Apache-2.0 people and object tracking on video, image folders, or streams with Trackflow (ONNX detectors + ByteTrack/BoT-SORT/OC-SORT/BoostTrack), export Parquet/JSONL/MOTChallenge, count line crossings, search tracks by text, project onto a floorplan, or anonymize footage. Use when the user asks to track objects/people in video, count crossings, search video tracks, inspect tracking runs locally, or replace Google Cloud Video Intelligence / AWS Rekognition person tracking without A...
177 stars
0 votes
0 copies
0 views
Added December 5, 2026
ai-agentspythongobashsqlawsdebugginggitapi
Works with
claude code
cli
api
mcp
Security analysis
A96/100
mediumInstalls packages at runtime which could introduce malicious dependencies
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Trackflow?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/aicodedecode-trackflow)
---
name: trackflow
description: Run local Apache-2.0 people and object tracking on video, image folders, or streams with Trackflow (ONNX detectors + ByteTrack/BoT-SORT/OC-SORT/BoostTrack), export Parquet/JSONL/MOTChallenge, count line crossings, search tracks by text, project onto a floorplan, or anonymize footage. Use when the user asks to track objects/people in video, count crossings, search video tracks, inspect tracking runs locally, or replace Google Cloud Video Intelligence / AWS Rekognition person tracking without AGPL licenses.
---
# Trackflow
Local people and object tracking via `trackflow-python` (Apache-2.0 CLI, Python streaming API, and WebGPU browser demo at `https://obendidi.github.io/trackflow/`).
## Quickstart
Run without installing via `uvx`, or install once with `pip`/`uv` (never keep both CPU `onnxruntime` and `onnxruntime-gpu` in the same environment):
```bash
uvx trackflow-python run street.mp4 # CPU / macOS (auto-pins Apple P-cores)
uvx trackflow-python run street.mp4 --device coreml # macOS Apple Silicon GPU
uvx trackflow-python-cuda run street.mp4 # NVIDIA CUDA (bundled CUDA + cuDNN)
uvx trackflow-python-tensorrt run street.mp4 # NVIDIA TensorRT FP16 (Py 3.11+, cached engines)
# or
pip install trackflow-python # or trackflow-python-cuda / trackflow-python-tensorrt
trackflow run street.mp4
trackflow inspect # opens local web UI on the latest run
```
- Each run writes to a fresh directory (`runs/run-1`, `runs/run-2`, ...). `-o <dir>` must be empty so runs never mix.
- Pass `--no-video` for batch analytics / exports when you do not need an annotated MP4.
- Sources accepted: video file, image folder (natural sort; pass `--fps`), RTSP/HTTP URL, or camera index (`0`).
## Choosing Detector, Tracker, and Device
Check available presets anytime with `trackflow models --json` and local acceleration with `trackflow info --json`.
| Need | Flags | Notes |
| :--- | :--- | :--- |
| Best permissive default (crowded scenes) | `-m rtdetr-v2-r18` *(default)* | Apache-2.0, ~81 MB, 45.1 MOT17 val HOTA (ByteTrack) |
| Fast on Apple Silicon / WebGPU | `-m rfdetr-nano` | Apache-2.0, ~108 MB |
| Smallest download | `-m dfine-n` | Apache-2.0, ~15 MB |
| Highest preset accuracy | `-m rfdetr-large` | Apache-2.0; requires `pip install "trackflow-python[transformers]"` |
| Fastest tracker | `-t bytetrack` *(default)* | Best speed; 45.1 HOTA on MOT17 val |
| Fewest ID switches / moving camera | `-t botsort --reid osnet` | Camera motion comp + person Re-ID; 46.1 HOTA, 170 ID switches |
| Heavy occlusions | `-t ocsort` or `-t boosttrack` | Re-matches after occlusions; BoostTrack+OSNet is slower |
- **Weight licenses**: Trackflow and `rtdetr-v2-r18`, `rfdetr-*`, `dfine-n` are **Apache-2.0**. `yolo26*` presets are **AGPL-3.0** and `deimv2-*` are **non-commercial** — warn the user before using them in commercial code.
- **Devices**: `--device auto|cpu|cuda|coreml|tensorrt` (ONNX) or `mps` (`hf:` Transformers). On Apple Silicon, `--device coreml` runs `rtdetr-v2-r18` at ~CPU speed with ~1/3 the CPU core load; `rfdetr-*` is faster on `cpu`.
## Common Workflows
### 1. Export tracks to Parquet and query with DuckDB
```bash
trackflow run crowd.mp4 --tracker botsort --reid osnet \
--classes person,backpack --export parquet,jsonl,csv,mot,html --no-video
```
```sql
SELECT track_id, COUNT(*) AS frames, AVG(confidence) AS avg_conf
FROM 'runs/run-1/tracks.parquet'
GROUP BY track_id ORDER BY frames DESC;
```
### 2. Count directional line crossings
```bash
trackflow run entrance.mp4 --line "door=640,300,640,720"
```
- Format: `[name=]x1,y1,x2,y2` in image pixels (repeatable).
- Crossing to the right of `(x1,y1) -> (x2,y2)` counts as `in`, opposite as `out`, after a `0.3 s` hold to filter box jitter. Place lines where feet remain visible.
- Totals land in `summary.json` (`line_counts`), HTML report, and `events.json` (`line_crossed`).
### 3. Natural-language track search (and Re-ID caveat)
```bash
# Embed track crops during the run (--vlm embeddinggemma needs `pip install "trackflow-python[transformers]"`)
trackflow run mall.mp4 --query "person in red jacket with a backpack" --vlm embeddinggemma
# Re-query the saved run later without re-running detection
trackflow search runs/run-1 "person carrying a suitcase"
```
- **Pick the search model**: `--vlm embeddinggemma` (EmbeddingGemma 2, PyTorch) is the most accurate on clothing and accessories; `--vlm siglip` is the best ONNX-only choice; CLIP, the default with `--query`, is the weakest. Each has its own `--query-threshold` default (0.71, 0.08, 0.27), so don't carry a threshold over from another model.
- **Keep search and identity separate**: CLIP, SigLIP and EmbeddingGemma 2 match text to track crops and are never used for track IDs. Use `--reid osnet` (and opt-in `--reid-merge` for re-entry linking) for appearance identity.
### 4. Visual debugging, comparison, and floorplan homography
```bash
trackflow compare crowd.mp4 --trackers bytetrack,botsort --inspect
trackflow inspect runs/run-1 # jump to ID switches, search cards, 4-point floorplan
```
### 5. Anonymization
```bash
trackflow run lobby.mp4 --anonymize face-blur # top 30% of each person box (box heuristic, not a face detector)
trackflow run lobby.mp4 --anonymize blur # or pixelate / skeleton (no source pixels saved)
```
- Anonymized runs suppress saving person crops/thumbnails; `--roll-seconds` runs skip them by default (`--save-crops` / `--no-save-crops` override). Recommend `blur` or `pixelate` over `face-blur` when subjects bend, sit, or are partially cropped.
### 6. Python streaming API (no disk writes)
```python
import cv2
from trackflow import TrackflowPipeline
from trackflow.lines import CountingLine
pipeline = TrackflowPipeline(
model="rfdetr-nano",
tracker="botsort",
lines=[CountingLine("door", (640, 300), (640, 720))],
)
cap = cv2.VideoCapture("rtsp://camera.local/stream")
def frames():
while True:
ok, frame = cap.read()
if not ok:
return
yield frame # BGR uint8
for result in pipeline.stream(frames(), fps=25):
for track in result.tracks:
print(result.frame_idx, track.track_id, track.class_name, track.bbox)
```
### 7. Answer questions from run folders over MCP
Prefer querying finished or rolling runs over reading video frames yourself: the run folder already holds every track, crossing and search embedding.
```bash
# Expose a folder of runs to an MCP client (Claude Code shown; absolute path)
claude mcp add trackflow -- uvx --from "trackflow-python[mcp]" trackflow mcp /path/to/runs
# Record a camera all day so the server can read it while it runs (one closed segment per minute)
trackflow run "$CAMERA_URL" --line "door=640,300,640,720" --roll-seconds 30 --max-segments 2880 --camera-id door # new runs/run-N per start
```
- Tools: `list_runs`, `live_status`, `query_line_counts`, `query_dwell` (zones need `--homography`), `query_sql` (read-only DuckDB over `tracks`, `events`, `track_cards`; 200 rows by default), `search_tracks` (needs `--query` or `--vlm` at record time), `export_clip` (blurred MP4 by default).
- Live cameras: poll `live_status` for online/offline/unknown, people in view and line totals; subtract two readings with the same `run_id` to get new crossings. For exact windows, call `query_line_counts` with `min_wall_time_utc`/`max_wall_time_utc` and keep the end at or before `closed_through_utc` (data before it is final).
- Closed segments trail the camera by up to `--roll-seconds`. A restarted camera writes a new run folder with the same `--camera-id`.
- The server must run on the machine that holds the runs; for a remote box use `ssh host "uvx --from 'trackflow-python[mcp]' trackflow mcp /srv/runs"` as the command.
## Boundaries
- Single video/stream per process — not a multi-camera VMS or alert server.
- FPS and track counts do not prove ID accuracy; for accuracy evaluation, export `--export mot` and score with TrackEval (or run `scripts/eval_mot17.py`).