8. API Reference

SpiriDetect: detections, the shared language of what’s out there.

Anything that finds something publishes a detection; anything that wants to know what’s out there reads detections; neither needs to know about the other.

class SpiriDetect.BearingDetection(synq_topic, synq_base_topic=None, synq_session=<factory>, synq_authoritive=False, synq_lazy_publish=False, synq_publish=True, synq_receive=True, synq_auto_start=True, synq_check_receive_types=True, synq_auto_rehydrate_on_missing_parent_timeout=5.0, synq_mtime=-1, synq_is_deleted=False, _synq_callbacks=<factory>, _synq_last_rehydrate_time=0.0, relative_to='unknown', mount=None, pose=None, _parent_subscriber=None, _parent_pose=None, _parent_live=False, _parent_generation=0, cot_type='b-m-p-s-p-i', label=None, confidence=None, time=None, stale_after=None, course=None, speed=None, azimuth=0.0, elevation=0.0, range=None, range_accuracy=None, bearing_accuracy=None, ray=None)[source]

Bases: Detection

Something seen along a bearing from a sensor.

relative_to links to the sensor’s frame (FRD: x where it points), and the bearing is in that frame: azimuth to the right of its x axis, elevation above it. Set them with set_bearing(), which sets the mount: oriented along the bearing, so the detection’s own x axis is the ray, and range metres out along it.

ray is the sensor’s place facing down the bearing, its accuracy the sensor’s, and bearing_accuracy is the cone’s half-angle. It’s there with or without a range, so a map can draw the frustum either way.

pose is the thing’s place, so only with a range: there the beam’s error, range_accuracy along it and bearing_accuracy across it, is added to the sensor’s own accuracy, split horizontal and vertical by the beam’s elevation above the horizon. Without a range pose is None.

Parameters:
  • synq_topic (str)

  • synq_base_topic (str | None)

  • synq_session (Session | None)

  • synq_authoritive (bool)

  • synq_lazy_publish (bool)

  • synq_publish (bool)

  • synq_receive (bool)

  • synq_auto_start (bool)

  • synq_check_receive_types (bool)

  • synq_auto_rehydrate_on_missing_parent_timeout (float)

  • synq_mtime (float)

  • synq_is_deleted (bool)

  • _synq_callbacks (dict)

  • _synq_last_rehydrate_time (float)

  • relative_to (RootFrame | Link | str)

  • mount (Pose | None)

  • pose (Pose | None)

  • _parent_subscriber (Subscriber | None)

  • _parent_pose (Pose | None)

  • _parent_live (bool)

  • _parent_generation (int)

  • cot_type (str | None)

  • label (str | None)

  • confidence (float | None)

  • time (float | None)

  • stale_after (float | None)

  • course (float | None)

  • speed (float | None)

  • azimuth (float)

  • elevation (float)

  • range (float | None)

  • range_accuracy (float | None)

  • bearing_accuracy (float | None)

  • ray (Pose | None)

set_bearing(azimuth, elevation=0.0, range=None)[source]

Point along azimuth/elevation (deg, in the sensor’s frame), range m out.

Parameters:
Return type:

None

clear()[source]

Nothing seen right now: no place, until the next bearing.

Return type:

None

class SpiriDetect.BoxDetection(synq_topic, synq_base_topic=None, synq_session=<factory>, synq_authoritive=False, synq_lazy_publish=False, synq_publish=True, synq_receive=True, synq_auto_start=True, synq_check_receive_types=True, synq_auto_rehydrate_on_missing_parent_timeout=5.0, synq_mtime=-1, synq_is_deleted=False, _synq_callbacks=<factory>, _synq_last_rehydrate_time=0.0, relative_to='unknown', mount=None, pose=None, _parent_subscriber=None, _parent_pose=None, _parent_live=False, _parent_generation=0, cot_type=None, label=None, confidence=None, time=None, stale_after=None, course=None, speed=None, azimuth=0.0, elevation=0.0, range=None, range_accuracy=None, bearing_accuracy=None, ray=None, box=None, angular_width=None, angular_height=None)[source]

Bases: BearingDetection

A box around something in a camera’s picture: a detector’s output.

relative_to links to the camera. Through its lens (SpiriCamera’s Camera.intrinsics) the box’s centre is a bearing and its size an angular footprint, angular_width by angular_height. There’s usually no range, so no pose: a map draws a narrow frustum down the ray.

label is the detector’s class and confidence its score. One object per tracked thing: the tracker’s id is the detection’s id, so a detector without a tracker makes a new detection per box.

Parameters:
  • synq_topic (str)

  • synq_base_topic (str | None)

  • synq_session (Session | None)

  • synq_authoritive (bool)

  • synq_lazy_publish (bool)

  • synq_publish (bool)

  • synq_receive (bool)

  • synq_auto_start (bool)

  • synq_check_receive_types (bool)

  • synq_auto_rehydrate_on_missing_parent_timeout (float)

  • synq_mtime (float)

  • synq_is_deleted (bool)

  • _synq_callbacks (dict)

  • _synq_last_rehydrate_time (float)

  • relative_to (RootFrame | Link | str)

  • mount (Pose | None)

  • pose (Pose | None)

  • _parent_subscriber (Subscriber | None)

  • _parent_pose (Pose | None)

  • _parent_live (bool)

  • _parent_generation (int)

  • cot_type (str | None)

  • label (str | None)

  • confidence (float | None)

  • time (float | None)

  • stale_after (float | None)

  • course (float | None)

  • speed (float | None)

  • azimuth (float)

  • elevation (float)

  • range (float | None)

  • range_accuracy (float | None)

  • bearing_accuracy (float | None)

  • ray (Pose | None)

  • box (PixelBox | None)

  • angular_width (float | None)

  • angular_height (float | None)

set_box(box, lens, range=None)[source]

Place box, seen through lens, as a bearing (and range m, if known).

A lens measured at another resolution is scaled to the box’s image, assuming the same aspect.

Parameters:
Return type:

None

class SpiriDetect.Detection(synq_topic, synq_base_topic=None, synq_session=<factory>, synq_authoritive=False, synq_lazy_publish=False, synq_publish=True, synq_receive=True, synq_auto_start=True, synq_check_receive_types=True, synq_auto_rehydrate_on_missing_parent_timeout=5.0, synq_mtime=-1, synq_is_deleted=False, _synq_callbacks=<factory>, _synq_last_rehydrate_time=0.0, relative_to='unknown', mount=None, pose=None, _parent_subscriber=None, _parent_pose=None, _parent_live=False, _parent_generation=0, cot_type=None, label=None, confidence=None, time=None, stale_after=None, course=None, speed=None)[source]

Bases: Position

Something a producer found, and where, if it knows.

pose is where the thing is, or None while that’s unknown. It is never a stand-in such as the sensor’s own place: a subclass with a partial fix (a bearing, say) keeps it in a field of its own.

cot_type is Cursor on Target’s type (a-u-G, b-m-p-s-p-i…), the vocabulary TAK and the rest of the world already speak. It sits in the object, not the key, so a detection keeps its identity when what it is becomes clearer. Producers set only the “what” part; affiliation is someone else’s decision.

confidence is the producer’s own, 0 to 1, that the thing is there and is what it says: a detector’s score, say. None means not given, which is honest for most sources (CoT carries none). It is not the position’s accuracy, which is pose.accuracy.

time is when the current state was observed, in Unix seconds: the pose tree doesn’t timestamp poses. stale_after is how many seconds past time a consumer should stop believing it if nothing updates it, as CoT’s stale time; None means it holds until closed.

course and speed are over the ground, as CoT’s track, for a thing whose motion the producer knows. Its heading, if it has one, is the pose’s orientation.

Parameters:
  • synq_topic (str)

  • synq_base_topic (str | None)

  • synq_session (Session | None)

  • synq_authoritive (bool)

  • synq_lazy_publish (bool)

  • synq_publish (bool)

  • synq_receive (bool)

  • synq_auto_start (bool)

  • synq_check_receive_types (bool)

  • synq_auto_rehydrate_on_missing_parent_timeout (float)

  • synq_mtime (float)

  • synq_is_deleted (bool)

  • _synq_callbacks (dict)

  • _synq_last_rehydrate_time (float)

  • relative_to (RootFrame | Link | str)

  • mount (Pose | None)

  • pose (Pose | None)

  • _parent_subscriber (Subscriber | None)

  • _parent_pose (Pose | None)

  • _parent_live (bool)

  • _parent_generation (int)

  • cot_type (str | None)

  • label (str | None)

  • confidence (float | None)

  • time (float | None)

  • stale_after (float | None)

  • course (float | None)

  • speed (float | None)

is_stale(now)[source]

Whether, at now (Unix seconds), this is past its stale time.

Parameters:

now (float)

Return type:

bool

class SpiriDetect.PixelBox(left, top, width, height, image_width, image_height)[source]

Bases: object

A box in an image, in pixels from its top-left corner.

Parameters:
SpiriDetect.beam_accuracy(distance, elevation, along, pointing)[source]

The 90% bounds of a spot at distance along a beam, level and plumb.

along is the error along the beam (m) and pointing the error off it (deg), which puts the spot distance * tan(pointing) off sideways. Each is split between horizontal and vertical by the beam’s elevation (deg above the horizon; level if unknown) and summed in quadrature, as Accuracy sums independent errors. A sideways error is horizontal one way and partly vertical the other, so horizontal takes all of it. Unknown errors are left out; with neither known, so is the accuracy.

Parameters:
Return type:

Accuracy | None

SpiriDetect.detection_topic(producer, id)[source]

The relative topic of producer’s detection id, under this node’s base topic.

Parameters:
Return type:

str

SpiriDetect.self_topic()[source]

The relative topic of this node’s report of itself.

Return type:

str