spatial_filter is a stateless workflow node that drops detections
that lie outside an author-defined polygon zone. It pairs with
timed_condition downstream to build zone-based
intrusion alerts without per-camera pixel coordinates.
Execution context is inferred from the upstream graph:
- Wired downstream of a
camera_frametrigger +call_modelchain it is compiled into the edge worker as an inline polygon-membership comprehension. - Wired anywhere else it runs in the cloud workflow runner against the detection array of the upstream node.
Coordinate system
Polygons are stored as[[x, y], ...] of floats in
normalized [0..1] image coordinates — the same space YOLO
bounding boxes already use. A zone authored against a 1080p stream
keeps working when you swap the camera for a 4K one without any
manual remap. Polygons must have at least 3 vertices.
Inputs
Outputs
Authoring zones
Zones are authored in the workflow editor inspector for thespatial_filter node:
- Add a
Spatial Filternode from the Decision & Control group. - Wire a
camera_frametrigger upstream (typically through acall_modelthat runs detection). - In the inspector, click on the polygon canvas to add vertices, drag to move them, double-click to remove (≥ 3 vertices required).
- Optional: click Capture frame to fetch the latest still from the upstream camera trigger and trace the polygon over the actual scene.
- Pick the Reference Point that matches your subjects:
bbox_bottom_centerfor people standing on the floor,centroidfor mid-air objects,any_overlapwhen even a finger crossing the line should count.
Edge implementation
The node compiles into a Python comprehension inlined into the generated edge worker (wf_<uuid8>.py) — no extra runtime
dependencies, no MQTT round-trip per frame. The polygon-membership
helper is generated only once even if multiple zones share a worker.
See Edge Workers for the full lifecycle.
Companion nodes
timed_condition— fire only when something has been inside the zone for at least N seconds.anonymize— pair upstream ofspatial_filterto publish privacy-safe video while still alerting on zone violations.