# PTZ Tracker — Modular Version ## Structure ``` ptz_tracker_modular/ ├── app.py # entrypoint (async main) ├── calibration.py # preset/sector and pan-sign calibration ├── config.py # constants + camera config ├── events.py # alarms, detection event plumbing ├── geom.py # angular math and sector helpers ├── heartbeat.py # UDP heartbeat ├── model.py # YOLO loading + forward ├── patrol.py # patrol logic (bounded/smooth + sync) ├── postprocess.py # PTZ control + zoom + notify_detected ├── preview.py # JPEG encode and preview publishing ├── ptz_io.py # PTZ HTTP session + worker + bounded move ├── sector.py # sector init and autocalculation ├── state.py # runtime shared state ├── status.py # PTZ status poller ├── streaming.py # WS servers, MicroBatcher, CPP bridges └── __init__.py ``` ## Run ```bash python -m ptz_tracker_modular.app ``` Optional env: - `YOLO_WEIGHTS=/path/to/weights.pt` - `CAM__PASSWORD=...` for every camera id Dependencies: `opencv-python`, `torch`, `ultralytics`, `websockets`, `requests`, `numpy`.