# ZMQ Video Streaming and Motion Detection This project implements a distributed video streaming and motion detection system using ZeroMQ (ZMQ) for messaging between clients, a router/proxy, and workers. The system is designed for real-time video processing, motion detection, and efficient message routing in a multi-camera environment. ## Features - **Client**: Captures video from one or more cameras, detects motion using OpenCV, and sends video frames and motion events to the router. - **Router**: Acts as a ZMQ proxy, routing messages between clients and workers, with message retention and worker assignment logic. - **Worker**: Receives video frames and events, processes or stores them, and can send control messages back to clients. - **Motion Detection**: Uses frame differencing and contour analysis to detect movement in video streams. ## Components - `client.py`: Captures video, detects motion, and sends frames/events to the router. - `router.py`: Routes messages between clients and workers, manages worker availability, and buffers undelivered messages. - `worker.py`: Receives and processes video frames, handles start/stop events, and manages per-camera video threads. - `helpers.py`: Utility functions and custom logging formatter. ## Requirements - Python 3.7+ - [ZeroMQ (pyzmq)](https://pypi.org/project/pyzmq/) - [OpenCV (cv2)](https://pypi.org/project/opencv-python/)