NetGear_Async API¶
Overview¶
NetGear_Async is an asyncio port of NetGear API that provides complete server-client handling with various options to use variable protocols/patterns similar to NetGear, but lacks in term of flexibility as it supports only Bidirectional Mode and Secure Mode (CURVE encryption, without
allowed_ipswhitelist) out of all NetGear's Exclusive Modes.
NetGear_Async is built on zmq.asyncio for lag-free video streaming over the network with minimal resource constraints. When NetGear_Async creates its own event loop, it uses the high-performance uvloop event loop (if installed, not on Windows).
NetGear_Async provides complete server-client handling and options to use variable protocols/patterns similar to NetGear API. Furthermore, NetGear_Async allows us to define our custom Server as source to transform frames easily before sending them across the network(see this doc example).
NetGear_Async now supports additional bidirectional data transmission between receiver(client) and sender(server) while transferring frames. Users can easily build complex applications such as like Real-Time Video Chat in just few lines of code.
In addition to all this, NetGear_Async API also provides internal wrapper around VideoGear, which itself provides internal access to CamGear, PiGear, and FFGear APIs, thereby granting it exclusive power for transferring frames incoming from any source to the network.
NetGear_Async as of now supports four ZeroMQ messaging patterns:
-
zmq.PAIR(ZMQ Pair Pattern) -
zmq.REQ/zmq.REP(ZMQ Request/Reply Pattern) -
zmq.PUB/zmq.SUB(ZMQ Publish/Subscribe Pattern) -
zmq.PUSH/zmq.PULL(ZMQ Push/Pull Pattern)
Whereas supported protocol are: tcp and ipc.
Event Loop handling
NetGear_Async never changes the global (process-wide) event loop policy. If it is created inside a running event loop (for e.g. inside asyncio.run()), it uses that loop. Otherwise it creates and owns a new event loop (uvloop if installed and not on Windows, else the default asyncio loop), available as its loop attribute. See this usage example âž¶ for running it inside asyncio.run().
Both ends must run the same vidgear version
NetGear_Async transfers each frame as a single ZeroMQ multipart message: a small msgspec-validated msgpack header followed by the raw frame buffer. This wire format is incompatible with NetGear_Async from older vidgear versions (which used msgpack + msgpack_numpy), so both Server and Client must be upgraded together, otherwise recv_generator() raises a clear ValueError. Malformed or hostile messages (for e.g. object dtype or size mismatch) are rejected with a ValueError too, and are never unpickled.
Received frames are writeable
Frames yielded by recv_generator() are regular writeable numpy.ndarray arrays, so you can draw on them (for e.g. with cv2.putText) directly.
Limitations
Unlike NetGear API, NetGear_Async does NOT support Lazy Pirate reconnection (i.e. its max_retries handling), SSH Tunneling Mode, or Secure Mode's allowed_ips whitelist (only secure_mode CURVE encryption is supported). Use NetGear API if you need any of these. Also, any TimeoutError (see timeout) ends recv_generator(), so the Client must be restarted.
 
Helpful Tips
-
It is advised to enable logging(
logging = True) on the first run for easily identifying any runtime errors. -
It is advised to comprehend NetGear API before using this API.
 
Usage Examples¶
After going through NetGear_Async Usage Examples, Checkout more bonus examples here âž¶
Parameters¶
References¶
FAQs¶