Skip to main content

picture_irball_detect

picture_irball_detect is a pip-installable image detector for infrared marker balls. It packages the trained MarkerNet ONNX weights, the production post-processing settings, a Python API, a command-line interface, and a Tkinter desktop interface.

The default installation is self-contained: the model is shipped inside the wheel, and no model download is required. The default backend is auto: it tests the existing CUDA environment by running a small inference with the selected model. CUDA is used only if that probe succeeds; otherwise the detector uses CPU ONNX Runtime. If ONNX Runtime itself is missing or broken, auto uses the installed OpenCV CPU backend instead.

Detector startup never downloads, installs, uninstalls, or repairs dependencies. It does not require network access, nvidia-smi, or NVIDIA Python package metadata to select a backend.

Example

This historical evaluation frame contains eight infrared marker balls. The detector found all eight balls with no false positives in that evaluation run.

Both images are included in the repository root and the source distribution:

  • example_original.jpg: the original, unannotated JPEG to use as detector input.
  • example.jpg: the annotated historical detection result for visual comparison.

The original is copied byte-for-byte from capture 2026-11-13_20-40-27.011729+0800, frame raw_0000100.jpg.

Original image

Original image containing eight infrared marker balls without annotations

Annotated result

Eight infrared marker balls detected in an example frame

After installation, run this from the repository root to detect the balls in the original image:

uv run --no-sync picture-irball-detect example_original.jpg --output-dir results

Install with uv

uv venv
uv pip install .

For development:

uv sync --group dev
uv run --no-sync pytest
uv run --no-sync ruff check src tests

The package requires Python 3.10 or newer. The Tkinter GUI also requires a Python distribution with Tk support. The standard Windows Python installer includes it.

These installation commands can download dependencies when you explicitly run them. The optional gpu extra is also available for manual environment setup; the detector never installs it itself. Using uv run --no-sync after setup prevents uv from synchronizing dependencies before startup.

Optional GPU dependencies (manual installation)

For an NVIDIA GPU on Windows x64 or Linux x86_64, first complete the base installation above, then close any running detector or Python process using this environment. Install or update the NVIDIA driver separately; the commands below install Python runtime libraries, not the GPU driver. The CUDA and cuDNN downloads can be large. Run these commands yourself when you want GPU support.

From the repository root, use PowerShell on Windows:

uv pip uninstall --python .venv\Scripts\python.exe onnxruntime
uv pip install --python .venv\Scripts\python.exe --reinstall-package onnxruntime-gpu "onnxruntime-gpu[cuda,cudnn]>=1.20,<2"

On Linux, use:

uv pip uninstall --python .venv/bin/python onnxruntime
uv pip install --python .venv/bin/python --reinstall-package onnxruntime-gpu "onnxruntime-gpu[cuda,cudnn]>=1.20,<2"

The [cuda,cudnn] extras install the CUDA and cuDNN runtime dependencies as well as GPU ONNX Runtime. Do not keep both onnxruntime and onnxruntime-gpu installed: they share the onnxruntime Python module. The first command removes the CPU distribution; the second forces reinstallation of the GPU distribution to restore shared files even if it was already installed.

Verify GPU inference with the original example image:

uv run --no-sync picture-irball-detect example_original.jpg --backend cuda --output-dir results

A successful run reports "backend": "cuda" and "provider": "CUDAExecutionProvider" in the JSON output. This explicit cuda check fails if GPU inference is unavailable; it cannot silently pass on CPU. For everyday use, omit --backend cuda to keep automatic CPU fallback.

Keep using uv run --no-sync after this manual setup. The base project declares the CPU onnxruntime dependency, so a plain uv sync or reinstalling the base project can bring it back; repeat the two manual setup commands if that happens. The application itself never runs them.

Python API

from picture_irball_detect import MarkerDetector, annotate
import cv2

image = cv2.imread("frame.jpg")
with MarkerDetector() as detector:
    balls = detector.detect(image)
    overlay = annotate(image, balls)
    cv2.imwrite("frame_overlay.png", overlay)

for ball in balls:
    print(ball.as_dict())

detect accepts a uint8 BGR OpenCV image. Each Ball contains center_x, center_y, radius, and score in original image pixels. score is a heatmap response, not a calibrated probability.

Custom settings and weights

The packaged default settings are available with:

picture-irball-detect --print-default-config

Copy that JSON file and edit it, then pass the copy to the API or CLI:

picture-irball-detect frame.jpg --config my_detector.json --model my_marker_net.onnx

The model_path setting may also point to a custom ONNX file. A relative model path in a custom configuration is resolved relative to that configuration file. Custom models must produce the same (1, 4, 32, 32) output layout as the bundled MarkerNet model.

The main settings are threshold, min_radius, max_radius, max_side, flip_ensemble, backend, threads, scale_filter, pattern_filter, and parallel_views.

CLI

Detect one image and print JSON:

picture-irball-detect frame.jpg

Write JSON results and an orange-yellow overlay for each input:

picture-irball-detect frame.jpg another.jpg --output-dir results

Useful overrides:

picture-irball-detect frame.jpg --backend onnxruntime --threshold 0.35 --no-pattern-filter
picture-irball-detect frame.jpg --backend cuda
picture-irball-detect frame.jpg --backend opencv

Backend selection

  • auto probes CUDA using the selected model and a small 64x64 sample. The probe must complete inference with valid, finite output, with CUDA still active and CPU fallback disabled. The validated session is reused for detection. A failed probe selects CPU ONNX Runtime, or OpenCV CPU if ONNX Runtime is unusable.
  • cuda performs the same probe, but reports an error instead of falling back if it fails.
  • onnxruntime uses CPU ONNX Runtime directly, without probing CUDA.
  • opencv uses OpenCV's CPU ONNX implementation directly, without importing ONNX Runtime.

Existing CUDA libraries are loaded through ONNX Runtime's default search paths. A listed CUDA provider or an installed GPU package alone is not treated as proof that GPU inference works. Fallback reasons are reported on stderr and in runtime_info["fallback_reason"].

Legacy auto_install_gpu configuration/API arguments and the --no-auto-install-gpu flag are accepted but ignored. PICTURE_IRBALL_AUTO_INSTALL_GPU is no longer read. None of these options can enable installation.

Tkinter GUI

picture-irball-detect-gui

The GUI can open an image, load a JSON configuration, select a model file, choose the backend, run detection, display the overlay, and save the annotated image. The configuration controls are intended for quick experiments; the Python API and JSON file are better for reproducible use.

Model provenance

The bundled model is the MarkerNet model used by the related image-aware detection service. It predicts a center heatmap, sub-cell center offsets, and marker radius. The default post- processing includes mirror-view fusion, isolated-scale filtering, and a local printed-grid filter to reduce checkerboard false positives.

The exact packaged model hash and training metadata are in src/picture_irball_detect/models/metadata.json.

Metadata

Release files for picture-irball-detect 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for picture-irball-detect 0.1.0
File Size Uploaded Provenance Actions
picture_irball_detect-0.1.0.tar.gz 1.6 MB Without provenance Details for picture_irball_detect-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for picture-irball-detect 0.1.0
File Interpreter ABI Platform Actions
picture_irball_detect-0.1.0-py3-none-any.whl Python 3 none any Details for picture_irball_detect-0.1.0-py3-none-any.whl

Total release size: 3.1 MB

Release files / picture_irball_detect-0.1.0.tar.gz

Download URL picture_irball_detect-0.1.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
d330a54117420727629a0791f1030aec60986be809be295fa00598866f2437f3
BLAKE2b-256 checksum
How to use checksums
8295f7e22a5edc0087e2399ae46b5b8c7909161d56a13077cc632b04cc691d48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Windows/11

Release files / picture_irball_detect-0.1.0-py3-none-any.whl

Download URL picture_irball_detect-0.1.0-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
e9a93abd93e53b9c7e9b8ab5f10655c5bfb6eb664521797e1eb87209cb52e31e
BLAKE2b-256 checksum
How to use checksums
013e7dd75c55f56e7cb018a0fbe211573849d0a375b3f979d022ba53b212dcaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Windows/11

Security for picture-irball-detect 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page