Updated Multi Server Mode for NetGear API (markdown) authored by Abhishek Thakur's avatar Abhishek Thakur
......@@ -4,13 +4,13 @@
# Multi-Server Mode for NetGear API
_This mode is exclusive designed NetGear API for robustly handling Multiple Servers at once, through exclusive Publish/Subscribe (`zmq.PUB/zmq.SUB`) messaging pattern, thereby providing access to seamless Live Streams across the various device in a network at the same time._ **This mode can be easily activated through `multiserver_mode` boolean attribute in [**option](netgear#parameters-and-attributes-wrench) dictionary parameter of the Netgear API during its initialization.**
_This mode is an exclusive designed NetGear API for robustly handling Multiple Servers at once, through Publish/Subscribe (`zmq.PUB/zmq.SUB`) and Request/Reply(`zmq.REQ/zmq.REP) messaging patterns, thereby providing access to seamless Live Streams across the various device in a network at the same time._ **This mode can be easily activated through `multiserver_mode` boolean attribute in [**option](netgear#parameters-and-attributes-wrench) dictionary parameter of the Netgear API during its initialization.**
### Key Points
* Enables Multiple Servers messaging support with a single client.
* Enables Multiple Server messaging support with a single client.
* Ability to [send any additional data](#2-advanced-multi-server-mode-implementation-with-custom-message-transfer-and-filter-support) of any datatype along with frames in real-time.
* Number of Servers can be extended to several 100s depending upon your System Hardware and requirements.
* Employs non-blocking Publish/Subscribe messaging pattern only.
* Employs Publish/Subscribe & Request/Reply messaging patterns.
* Each new Server on the network can be identified on the single Client's end by using its **unique port address**.
* API actively tracks the current state of each connected Server.
* If all the connected servers on the network get disconnected, the client itself automatically exits to save resources.
......@@ -27,7 +27,7 @@ _This mode is exclusive designed NetGear API for robustly handling Multiple Serv
* _The network IP [`address`](netgear#parameters-and-attributes-wrench) value of each Server MUST exactly match the Client._
* _If all the connected servers on the network get disconnected, the Client itself automatically exits to save resources._
* ***This feature as of now only available with the [`testing`](https://github.com/abhiTronix/vidgear/tree/testing) branch only!***
* _In Multi-Server Mode, even it is not advisable, when you're running all Multiple Servers and the Client on same local machine/system in different commandline windows, Avoid using NetGear API with other VidGear APIs (such as CamGear, PiGear) but instead stick to simple OpenCV methods(_usage given below_) to avoid undesired latency due to multiple threads._
* _In Multi-Server Mode, even it is not advisable, when you're running all Multiple Servers and the Client on same local machine/system in different command-line windows, Avoid using NetGear API with other VidGear APIs (such as CamGear, PiGear) but instead stick to simple OpenCV methods(_usage given below_) to avoid undesired latency due to multiple threads._
---
 
......@@ -72,7 +72,7 @@ cd
## 1. Multi-Server Mode implementation using OpenCV with NetGear API:
_In this example, we will capture live frames from Multiple Systems(a.k.a Servers) with a webcam using **OpenCV computer vision library** and then transferred over the network to another system(a.k.a Client) at the same time through NetGear API using its Multi-Server Mode through **Publisher/Subscriber** Messaging pattern with insignificant latency.._
_In this example, we will capture live frames from Multiple Systems(a.k.a Servers) with a webcam using **OpenCV computer vision library** and then transferred over the network to another system(a.k.a Client) at the same time through NetGear API using its Multi-Server Mode through **Request/Reply** Messaging pattern with insignificant latency.._
### A. Client's End Code:
Open a terminal on the System(_a Client, where you want to display the input frames received from Multiple Servers_) and execute the following python code. **Remember the IP-address of this system(_required at Server's end_) by executing the command: _'`hostname -I`'_** and also replace it in the following code:
......@@ -90,8 +90,8 @@ import cv2
#activate multiserver_mode
options = {'multiserver_mode': True}
#Change the Client with your system IP address and port address of each unique Server((5566,5567) in our case), plus activate pattern Pub/Sub(`2`), `recieve_mode`, and `logging` for debugging
client = NetGear(address = 192.168.x.x, port = (5566,5567), protocol = 'tcp', pattern = 2, receive_mode = True, **options)
#Change the Client with your system IP address and port address of each unique Server((5566,5567) in our case), plus activate pattern Request/Reply(`1`), `recieve_mode`, and `logging` for debugging
client = NetGear(address = 192.168.x.x, port = (5566,5567), protocol = 'tcp', pattern = 1, receive_mode = True, **options)
#define frame received dict
frame_dict = {}
......@@ -156,7 +156,7 @@ stream = cv2.VideoCapture(0)
options = {'multiserver_mode': True}
#change following IP address '192.168.1.xxx' with Client's IP address and assign unique port address(for e.g 5566).
server = NetGear(address = 192.168.x.x, port = '5566', protocol = 'tcp', pattern = 2, receive_mode = False, **options) # and keep rest of settings similar to Client
server = NetGear(address = 192.168.x.x, port = '5566', protocol = 'tcp', pattern = 1, receive_mode = False, **options) # and keep rest of settings similar to Client
# infinite loop until [Ctrl+C] is pressed
while True:
......@@ -201,7 +201,7 @@ stream = cv2.VideoCapture(1)
options = {'multiserver_mode': True}
#change following IP address '192.168.1.xxx' with Client's IP address and assign unique port address(for e.g 5566).
server = NetGear(address = 192.168.x.x, port = '5567', protocol = 'tcp', pattern = 2, receive_mode = False, **options) # and keep rest of settings similar to Client
server = NetGear(address = 192.168.x.x, port = '5567', protocol = 'tcp', pattern = 1, receive_mode = False, **options) # and keep rest of settings similar to Client
# infinite loop until [Ctrl+C] is pressed
while True:
......@@ -269,7 +269,7 @@ while True:
# receive data
data = client.recv()
# check if data received isn't None
# check if data received isn't None2
if data is None:
break
......
......