Zone-based counting
Count detections inside polygonal zones—ideal for traffic, retail, and other analytics.
Estimated read time: 4 minutes
Many applications (e.g., traffic, retail, safety) need counts within specific regions, not across the entire frame. Zone-based counting lets you define polygonal areas and track totals per zone, optionally per class. This guide uses a YOLOv8 detection model and an interactive zone tool so you can adjust zones live, without changing the code.
How it works
A detection model runs on each frame to identify objects.
A
ZoneCounteranalyzer checks which detections fall inside your polygons and updates the counts.You can interactively adjust zone vertices in the display window to fine-tune boundaries—no code changes needed.
Basic Zone Counter

Use this static setup when you want fixed polygon zones with automatic overlays. Update the coordinates in polygon_zones to match your scene so ZoneCounter can draw per-zone totals and populate inference_result.zone_counts.
Example
Interactive Zone Counter

Pick the interactive workflow when you need to reposition zones during a live session. Drag an entire polygon with the left mouse button, then right-click a corner handle to refine that vertex while the stream keeps running.
Example
Last updated
Was this helpful?

