supervision/examples/tracking
Jirka Borovec bcbe8de1e4
chore(pre-commit): remove unnecessary exclude rule for changelog... (#2452)
* chore(pre-commit): remove unnecessary exclude rule for changelog and deprecated docs
* docs(changelog): reformat code blocks for consistency and clarity
* docs(changelog): reformat and align code blocks for consistent indentation and readability
* chore(pre-commit): update mdformat hooks to include gfm and frontmatter extensions
* chore(pre-commit): split mdformat hook into gfm and mkdocs variants
* docs(changelog): fix nested code fences breaking mdformat-mkdocs
* fix(pre_commit): 🎨 auto format pre-commit hooks

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-21 19:33:35 +02:00
..
README.md chore(pre-commit): remove unnecessary exclude rule for changelog... (#2452) 2026-07-21 19:33:35 +02:00
inference_example.py examples/tracking: improve CLI argument parsing (#2058) 2026-02-03 12:52:50 +01:00
requirements.txt examples/tracking: improve CLI argument parsing (#2058) 2026-02-03 12:52:50 +01:00
ultralytics_example.py examples/tracking: improve CLI argument parsing (#2058) 2026-02-03 12:52:50 +01:00

README.md

tracking

👋 hello

This script provides functionality for processing videos using YOLOv8 for object detection and Supervision for tracking and annotation.

💻 install

  • clone repository and navigate to example directory

    git clone --depth 1 -b develop https://github.com/roboflow/supervision.git
    cd supervision/examples/tracking
    
  • setup python environment and activate it [optional]

    uv venv
    source .venv/bin/activate
    
  • install required dependencies

    uv pip install -r requirements.txt
    

🛠️ script arguments

  • ultralytics

    • --source_weights_path: Required. Specifies the path to the YOLO model's weights file, which is essential for the object detection process. This file contains the data that the model uses to identify objects in the video.

    • --source_video_path: Required. The path to the source video file to be processed. This is the video on which object detection and annotation will be performed.

    • --target_video_path: Required. The path where the processed video, with annotations added, will be saved. This is your output video file.

    • --confidence_threshold (optional): Sets the confidence level at which the model identifies objects in the video. Default is 0.3. A higher threshold makes the model more selective, while a lower threshold makes it more inclusive in identifying objects.

    • --iou_threshold (optional): Specifies the IOU (Intersection Over Union) threshold for the model, defaulting to 0.7. This parameter helps in differentiating between distinct objects, especially in crowded scenes.

  • inference

    • --roboflow_api_key (optional): The API key for Roboflow services. If not provided directly, the script tries to fetch it from the ROBOFLOW_API_KEY environment variable. Follow this guide to acquire your API KEY.

    • --model_id (optional): Designates the Roboflow model ID to be used. The default value is "yolov8x-1280".

    • --source_video_path: Required. The path to the source video file to be processed. This is the video on which object detection and annotation will be performed.

    • --target_video_path: Required. The path where the processed video, with annotations added, will be saved. This is your output video file.

    • --confidence_threshold (optional): Sets the confidence level at which the model identifies objects in the video. Default is 0.3. A higher threshold makes the model more selective, while a lower threshold makes it more inclusive in identifying objects.

    • --iou_threshold (optional): Specifies the IOU (Intersection Over Union) threshold for the model, defaulting to 0.7. This parameter helps in differentiating between distinct objects, especially in crowded scenes.

⚙️ run

  • inference

    python inference_example.py \
        --roboflow_api_key "ROBOFLOW_API_KEY" \
        --source_video_path input.mp4 \
        --target_video_path tracking_result.mp4
    
  • ultralytics

    python ultralytics_example.py \
        --source_weights_path yolov8s.pt \
        --source_video_path input.mp4 \
        --target_video_path tracking_result.mp4
    

© license

This demo integrates two main components, each with its own licensing:

  • ultralytics: The object detection model used in this demo, YOLOv8, is distributed under the AGPL-3.0 license. You can find more details about this license here.

  • supervision: The analytics code that powers the zone-based analysis in this demo is based on the Supervision library, which is licensed under the MIT license. This makes the Supervision part of the code fully open source and freely usable in your projects.