zone-analytics
Zone Analytics capability — spatial occupancy aggregations over tracked detections.
Zone Analytics capability — spatial occupancy aggregations over tracked detections. Hosted by addon-pipeline-analytics.
Live snapshot is mirrored into the zone-occupancy device-state slice on every frame; the cap method getCurrentSnapshot is a direct read for callers that don't want to subscribe.
History methods are sourced from a 60-minute rolling in-memory ring of frame-level samples (sub-second resolution). Queries outside the ring window return empty arrays — durable storage is a follow-up (Step 4b: persisted samples → SQL store).
Every history method takes an optional className filter:
- omitted → bucket count includes ALL classes in scope
- present → bucket count restricted to that class
The getZoneHistory / getCameraHistory / getUnzonedHistory triple covers the three spatial scopes (per-zone, frame-wide, outside-any-zone). Crossing them with className? gives the full combinatorial coverage the operator UI requested.
At a glance
| Capability | zone-analytics |
| Provided by | One addon provides it for every device and answers by device id. |
| Active providers per device | one |
| Device types | camera |
| Source | packages/types/src/capabilities/zone-analytics.cap.ts |
Methods
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
getCurrentSnapshot | query | yes | default |
getCurrentSnapshotBatch | query | yes | default |
getZoneHistory | query | yes | default |
getCameraHistory | query | yes | default |
getUnzonedHistory | query | yes | default |
getCurrentSnapshot
query
Latest computed occupancy snapshot for this camera. Null when the analytics pipeline hasn't seen a frame for this device yet (no inference result emitted since boot or since binding was activated).
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes |
Output
| Field | Type | Required | Description |
|---|---|---|---|
ts | number | yes | |
frameWidth | number | yes | |
frameHeight | number | yes | |
zones | ({ totalObjects: number; byClass: Record<string, number>; standingObjects?: number; transientObjects?: number; zoneId: string; zoneName: string; trackIds: string[] })[] | yes | |
frame | { totalObjects: number; byClass: Record<string, number>; standingObjects?: number; transientObjects?: number } | yes | |
unzoned | { totalObjects: number; byClass: Record<string, number>; standingObjects?: number; transientObjects?: number } | yes | |
stationaryObjects | ({ id: string; className: string; bbox: { x: number; y: number; w: number; h: number }; frameWidth: number; frameHeight: number; firstSeenAt: number; becameStationaryAt: number; lastConfirmedAt: number; label?: string; k… | no |
getCurrentSnapshotBatch
query
The same snapshot, for a SET of cameras, in one round trip.
The Events page's Stationary section polls this every 15s for every selected camera. Fanned out client-side that is one query per camera to read a Map.get at the owner — the answer costs nothing, the round trip costs everything. Batched, N transports become one and the per-device work is unchanged.
Every requested deviceId gets a row, tagged read — see { not answer for is 'unreadable', never an empty reading.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceIds | number[] | yes |
Output
({ deviceId: number; read: "read" | "unreadable"; snapshot: { ts: number; frameWidth: number; frameHeight: number; zones: ZoneScopeBreakdownSchema[]; frame: PerScopeBreakdownSchema; unzoned: PerScopeBreakdownSchema; stat…
getZoneHistory
query
Time-series object count inside one zone. className optional — omit to count every class in the zone.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
zoneId | string | yes | |
className | string | no | |
from | number | yes | |
to | number | yes | |
resolution | "minute" | "5min" | "hour" | yes |
Output
({ ts: number; count: number })[]
getCameraHistory
query
Time-series frame-wide object count (everywhere).
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
className | string | no | |
from | number | yes | |
to | number | yes | |
resolution | "minute" | "5min" | "hour" | yes |
Output
({ ts: number; count: number })[]
getUnzonedHistory
query
Time-series count of objects outside every zone.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
className | string | no | |
from | number | yes | |
to | number | yes | |
resolution | "minute" | "5min" | "hour" | yes |
Output
({ ts: number; count: number })[]
Runtime state
The state Dominevo keeps for each device with this capability, readable without calling the provider.
Runtime-state slice — the latest occupancy snapshot mirrored by the analytics frame processor on every inference result. Consumers read via device.state.zoneAnalytics.value and stay in sync automatically; the explicit getCurrentSnapshot cap method is still useful for one-off polls without a subscription.
| Field | Type | Required | Description |
|---|---|---|---|
ts | number | yes | Frame timestamp of the inference result that produced this snapshot. |
frameWidth | number | yes | Frame width/height in pixels — let the UI normalize bbox coords. |
frameHeight | number | yes | |
zones | ({ totalObjects: number; byClass: Record<string, number>; standingObjects?: number; transientObjects?: number; zoneId: string; zoneName: string; trackIds: string[] })[] | yes | Per-zone breakdown — one entry per defined zone (user + onboard). |
frame | { totalObjects: number; byClass: Record<string, number>; standingObjects?: number; transientObjects?: number } | yes | Frame-wide aggregate (everywhere, regardless of zone membership). INCLUDES currently-confirmed stationary objects (they are still present). |
unzoned | { totalObjects: number; byClass: Record<string, number>; standingObjects?: number; transientObjects?: number } | yes | Detections that landed outside every zone. Empty when no zones defined. |
stationaryObjects | ({ id: string; className: string; bbox: { x: number; y: number; w: number; h: number }; frameWidth: number; frameHeight: number; firstSeenAt: number; becameStationaryAt: number; lastConfirmedAt: number; label?: string; k… | no | Parked objects on this camera (additive — absent on legacy snapshots). Surfaced separately so the UI shows them in a dedicated section rather than as repeated tracks/events. |