Inspect any ONNX model in your browser

Polygon zone drawer for counting zones and ROIs

Zone counting, region-of-interest tests and area alerts all start with polygon coordinates, and hand-writing them is the worst part of the job. Load a frame, click out each region, and copy the coordinates as Python or JSON. Runs in your browser: nothing is uploaded, and your footage never leaves your machine.

Drop a video or an image here

It stays in this tab. Scrub to a frame, click out each zone corner by corner, then copy the coordinates as Python or JSON.

Zones

None yet. Load a frame and click out the first corner.

# Close at least one zone to see its coordinates here.

How to draw counting zones

  1. 1

    Drop a video or image

  2. 2

    Scrub to a clean frame

  3. 3

    Click out each zone

  4. 4

    Name and adjust zones

  5. 5

    Copy Python or JSON

What people use zones for

A zone is the cheapest piece of scene understanding there is: one polygon and a point test turn a detector into a system that answers a business question.

Retail people counting

Count shoppers per aisle, per display or per queue, and compare zones against each other across the day.

Queue length monitoring

A polygon over the queue area plus a per-frame count gives wait-time estimates without any extra hardware.

Restricted area alerts

Fire an event when a person or vehicle enters a zone they should not be in: loading bays, track sides, machine perimeters.

Dwell time analysis

Track how long each ID stays inside a zone to measure engagement at a display or congestion at a chokepoint.

Parking occupancy

One polygon per bay turns a detector into an occupancy map, angled bays included, no rectangles required.

Line crossing and direction

Two thin zones make a direction gate: entering A then B is one direction, B then A is the other.

From zones to a people counter

The Python export is the POLYGONS list the count people in zones with YOLO and OpenCV tutorial builds on: paste it in, and the rest of that walkthrough handles detection, tracking and per-zone counting.

import cv2
import numpy as np

# Paste the export from the drawer above:
POLYGONS = [
    # Zone 01
    [[192, 818], [1209, 1078], [1596, 1076], [241, 694]],
]

zones = [np.array(p, dtype=np.int32) for p in POLYGONS]

# Is this person inside zone 0? Test their feet, not the box centre.
inside = cv2.pointPolygonTest(zones[0], (x_feet, y_feet), False) >= 0

# Draw every zone on the frame.
cv2.polylines(frame, zones, isClosed=True, color=(0, 255, 0), thickness=2)

Tips for zones that behave

Test feet, not box centres

A person occupies the floor at their feet. Testing the bottom-centre of the bounding box against the polygon places a leaning or partially occluded person in the right zone; the box centre often does not.

Keep corners in walking order

Click corners in order around the region's edge, never across it. A polygon whose edges cross itself fills wrong with fillPoly and returns nonsense from pointPolygonTest.

Space the corners out

Two corners a few pixels apart add noise, not accuracy. The tutorial's sanitizer drops near-duplicate points below a minimum distance; drawing them cleanly here means it has nothing to fix.

Export normalized when you resize

If inference runs at a different resolution than the source, export normalized coordinates and multiply by the working frame size, so the zones survive every resize in the pipeline.

Zone drawing, answered

How do I get polygon zone coordinates for OpenCV or YOLO?
Load a frame from your camera or video into the drawer above, click out the corners of each region, and copy the result. The Python export is a POLYGONS list of [x, y] pixel pairs that drops straight into an OpenCV pointPolygonTest or fillPoly workflow, and the JSON export carries the same points with the frame size attached.
Is my video uploaded anywhere?
No. The file is decoded by your browser's own media stack, inside this tab. Nothing is uploaded, so footage from a real site or store never leaves your machine.
Why polygons instead of rectangles?
Real regions are rarely axis-aligned boxes. A slanted doorway, a curved queue or the floor rows of an escalator seen from an angled camera all need corners that follow the scene, and a polygon follows them where a rectangle cannot.
Do the coordinates match my full-resolution video?
Yes. Points are stored in the source frame's own pixel space, not the preview's. However small the preview is drawn in your browser window, the export is in the pixels of the original frame, so it is correct for the real video.
What is the normalized export for?
The normalize toggle divides every coordinate by the frame's width and height, giving values from 0 to 1. Use it when your pipeline resizes frames before the zone test: multiply the normalized points by the working resolution and the zones land in the right place at any size.
Can I define a region of interest (ROI) for object detection with this?
Yes, that is the same job under a different name. A counting zone, a detection ROI, a restricted area and an ANPR trigger region are all a polygon in frame coordinates; draw it here, export it, and test detections against it with pointPolygonTest or mask the frame with fillPoly before inference.

Keep going