2. Getting Started

2.1. Installation

SpiriDetect isn’t published yet. Until it is, depend on a checkout:

uv add --editable ../SpiriDetect

To work on it:

uv sync
uv run pytest

It needs Python 3.13 and SpiriSynq 0.6 or later.

2.2. Publishing a detection

A producer makes one detection per thing it sees, at a topic from detection_topic(): the producer’s name, then the thing’s id. It updates that object as the thing moves, and closes it when the thing is gone.

A camera tracker, for example, reports each tracked box through the camera’s lens:

from SpiriSynq.link import Link
from SpiriDetect import BoxDetection, PixelBox, detection_topic

person = BoxDetection(
    detection_topic("yolo", str(track_id)),
    synq_authoritive=True,
    relative_to=Link.to(camera),
    label="person",
    confidence=0.83,
)
person.set_box(PixelBox(412, 180, 36, 90, 1280, 720), camera.intrinsics)

# Each frame the tracker still has it:
person.set_box(new_box, camera.intrinsics)
person.time = frame_time

# When the tracker drops it:
person.close()

relative_to links the detection to the camera’s own Position, so as the camera (or the gimbal, or the aircraft) moves, the detection’s ray moves with it, with no work from the producer.

2.3. Reporting a node’s own position

A node reports itself at self_topic(), <host>/detections/self, as a plain Detection:

from SpiriSynq.example_types.position import Pose
from SpiriSynq.link import Link
from SpiriDetect import Detection, self_topic

me = Detection(self_topic(), synq_authoritive=True, relative_to=Link.to(airframe))
me.mount = Pose()  # at the airframe's origin
me.course, me.speed = 270.0, 12.5

2.4. Reading detections

Every detection matches */detections/*/*, and a node’s own report is <host>/detections/self. Mirror one with SpiriSynq, as any other object:

from SpiriDetect import Detection

d = Detection.from_topic("drone1/detections/yolo/17")
if d.pose is not None:
    print(d.pose.offset.to_geodetic(), d.pose.accuracy)

Check pose before using it: a detection without a place, such as a bearing without a range, has none. Check is_stale() before trusting an old one.

A watcher that keeps the live set of detections for readers is planned; see SpiriDetect: design notes.