SPESDK ReferencePython · Spatial Intelligence Engine Source ↗

Start with the SDK's local spatial core, HTTP client, and temporal analytics.

SPE SDK documentation

Edit source ↗
PYTHON SDK · SPATIAL INTELLIGENCE ENGINE

Build spatial intelligence
into your vision workflow.

Install spe-engine, import spe, and add calibration, tracking, and lane-aware spatial analytics to your vision workflow.

python -m pip install spe-enginePython import: spe
IMAGE SPACEfour-point calibration
→
REFERENCE PLANE
A1B1C1A2B2C2A3B3C3
track → cell → zone
01 / LOCAL

Spatialize in-process

No server required for calibration, transforms, inspection, or rendering.

from spe import SpatialEngine

points = [[180, 120], [1090, 150], [1180, 640], [90, 660]]
engine = SpatialEngine(grid_rows=4, grid_columns=6)
engine.calibrate(points, 1280, 720)
result = engine.inspect([640, 360])
Local spatial guide →
02 / HTTP

Connect to SPE

Use the typed sync client or its asyncio counterpart for server operations.

from spe import SPEClient

with SPEClient("http://127.0.0.1:5000") as client:
    print(client.health())
    print(client.list_models())
HTTP client guide →
03 / TEMPORAL

Track and measure

Associate detections, maintain motion state, and summarize zone events.

from spe import ModelAgnosticTracker

tracker = ModelAgnosticTracker()
tracked = tracker.update(detections, timestamp)
print(tracked["diagnostics"])
Tracking & analytics →
SDK REFERENCE

Installation

pip install spe-engine             # published package
pip install "spe-engine[http]"     # + optional httpx transport
pip install "spe-engine[docs]"     # + documentation tooling

# From a repository checkout:
pip install -e ".[dev]"           # + pytest, pytest-cov, ruff, mypy, build, twine

Runtime dependencies are numpy >= 1.24 and opencv-python-headless >= 4.8. The HTTP clients use only the standard library unless you opt into the httpx transport.

Supported Python versions: 3.10, 3.11, 3.12, 3.13, 3.14.

SDK REFERENCE

Architecture

The SDK exposes two independent surfaces that share one coordinate contract:

ModuleRole
spe.engineSpatialEngine — stateful, in-process facade.
spe.geometryHomography math and four-point calibration (OpenCV/NumPy).
spe.spatialPoint inspection and detection spatialization primitives.
spe.gridImage-space and calibrated grid rendering.
spe.zonesDeterministic semantic zone identifiers.
spe.trackingProvider-neutral multi-object association (ModelAgnosticTracker).
spe.motionBounded trajectories, velocity, direction, and prediction.
spe.observationsProvider-neutral timestamped observation builders.
spe.modelsTyped value objects over the JSON contracts.
spe.clientSPEClient — synchronous HTTP client for a running engine.
spe.aioAsyncSPEClient — asyncio wrapper around SPEClient.
spe.transportPluggable HTTP transports (urllib, requests, httpx).
spe.exceptionsThe SPEError hierarchy.
spe.cliThe spe command-line interface.

The local core (SpatialEngine plus the free functions) performs all geometry in-process and never needs a server. The HTTP client speaks to a running SPE engine server and mirrors the same spatial model.

SDK REFERENCE

Type aliases and version

  • spe.__version__ — the installed SDK version string (also printed by spe --version).
  • FileSource — the accepted input type for uploads: bytes | bytearray | memoryview | str | os.PathLike | BinaryIO. A str or os.PathLike is read from disk; bytes-like values are sent as-is; any object with a callable read is read as a binary stream.
SDK REFERENCE

Coordinate contract

Three coordinate systems are kept distinct:

  1. Image coordinates — source pixels, (x, y), origin at the top-left. Exposed with coordinate_system: "image_pixels" (or "source_pixels" for model detections).
  2. Reference coordinates — the calibrated plane, default 1000 x 600, units: "normalized". Exposed with coordinate_system: "calibrated_reference_plane". Physical units are only reported when the calibration was created with non-normalized units; the SDK never invents a physical scale.
  3. Grid coordinates — logical cells over the reference plane, plus semantic zones.

Calibration uses exactly four points in TL, TR, BR, BL order — top_left, top_right, bottom_right, bottom_left. Points must form a non-degenerate, non-self-intersecting quadrilateral inside the source frame.

A four-point calibration computes a 3 x 3 homography mapping image → reference (homography) and its inverse reference → image (inverse_homography).

Grid cells are zero-based row/column indices, exposed both as a GridCell and as a coordinate list in (column, row) order. Zones are human-readable ids built from a spreadsheet-style row label and a one-based column: A1, B3, AA2, ...