A premium, highly interactive utility to select and edit polygonal Regions of Interest (ROIs).
Project description
ZONER 🎯
A premium, highly interactive Python utility to select, edit, and manage polygonal Regions of Interest (ROIs) from images, video frames, or video files.
Features
- Left-Click: Add points
- Left-Click & Drag: Grab and move existing points
- Left-Click on Line: Insert a new point dynamically between two points
- Right-Click: Delete points
- ENTER: Save current zone / Exit when drawing is empty
- Z / Ctrl+Z: Undo last point
- R: Reset all points and zones
- Scroll Mouse Wheel: Zoom in and out centering on the cursor
- Export/Import JSON: Export with S, Import with L (saves as
{source}_zones.jsonautomatically) - Auto-Scale: Auto-scales large frames to fit display size while keeping original resolution coordinates
Installation
Install in editable mode from the project folder:
pip install -e .
How to Use (Different Ways)
Zoner is designed to be highly versatile. You can initialize it using video files, image files, or raw NumPy frame arrays.
1. Direct Video File Path (Default: Loads First Frame)
Ideal for quick setups when you just want to draw zones on the first frame of a video.
from zoner import ZoneSelector
# Load video directly (automatically reads frame 0)
selector = ZoneSelector("PETS2009.avi")
zones = selector.draw()
# Get results
for zone in zones:
print(f"Zone: {zone['name']}, Coordinates: {zone['points']}")
2. Specific Video Frame (By Frame Index)
Perfect if the first frame of your video is black or lacks context, and you want to choose a specific frame index (e.g., frame 150) to draw your zones.
import cv2
from zoner import ZoneSelector
# 1. Capture the exact frame
cap = cv2.VideoCapture("PETS2009.avi")
cap.set(cv2.CAP_PROP_POS_FRAMES, 150) # Jump to frame 150
ret, frame = cap.read()
cap.release()
if ret:
# 2. Pass the NumPy frame array to ZoneSelector
selector = ZoneSelector(frame, window_name="Select Zones on Frame 150")
# 3. Specify custom JSON filename to link it with the video name
selector.json_filename = "PETS2009_zones.json"
zones = selector.draw()
3. Specific Time Position in Video (By Seconds)
Useful when you want to jump to a specific time slot (e.g., 5.5 seconds) in the video.
import cv2
from zoner import ZoneSelector
cap = cv2.VideoCapture("PETS2009.avi")
fps = cap.get(cv2.CAP_PROP_FPS)
# Calculate frame number for 5.5 seconds
frame_num = int(5.5 * fps)
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_num)
ret, frame = cap.read()
cap.release()
if ret:
selector = ZoneSelector(frame, window_name="Select Zones at 5.5 Seconds")
selector.json_filename = "PETS2009_zones.json"
zones = selector.draw()
4. Direct Image File Path
Useful for static image analysis.
from zoner import ZoneSelector
# Load an image path
selector = ZoneSelector("workstation_layout.jpg")
zones = selector.draw()
5. Running from Command Line
You can test the module instantly from the command line:
python -m zoner.selector
(This starts a test session on the default PETS2009.avi video).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyzoner-0.1.0.tar.gz.
File metadata
- Download URL: pyzoner-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a066d18c9b742bc4ccce31432173994a309bacc4b33b0acbd309b63fac54807
|
|
| MD5 |
4687a42b6cf090c8ae8c4a49685f742d
|
|
| BLAKE2b-256 |
f88b68c7b3dc64b3f194ef49c7efee48f8ace964c1c4a72bb6d497ea8441c67e
|
File details
Details for the file pyzoner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyzoner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
919abc2babad5e663bbc4f0689bfc8abaf326a9dd4336f988b508c67834772c6
|
|
| MD5 |
95ed24e9908ba216bea97ab55b56dc99
|
|
| BLAKE2b-256 |
fc97474626e1c589ff0aeee18cab67de53f966387f000910de465b3faf78bf45
|