From 9f9b174e01bb3c869a12f15733f270bc180e3304 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 12:08:19 +0200 Subject: [PATCH 01/17] cam streaming script first draft added --- cam_streaming/client.py | 104 +++++++++++++++++++++++++ cam_streaming/config.yaml | 23 ++++++ cam_streaming/server.py | 154 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 281 insertions(+) create mode 100644 cam_streaming/client.py create mode 100644 cam_streaming/config.yaml create mode 100644 cam_streaming/server.py diff --git a/cam_streaming/client.py b/cam_streaming/client.py new file mode 100644 index 0000000..791e15d --- /dev/null +++ b/cam_streaming/client.py @@ -0,0 +1,104 @@ +import socket +import pickle +import cv2 +import struct +import sys +import yaml + + +def send_data(conn, payload, data_id=0): + """ + @brief: send payload along with data size and data identifier to the connection + @args[in]: + conn: socket object for connection to which data is supposed to be sent + payload: payload to be sent + data_id: data identifier + """ + # serialize payload + serialized_payload = pickle.dumps(payload) + # send data size, data identifier and payload + conn.sendall(struct.pack(">I", len(serialized_payload))) + conn.sendall(struct.pack(">I", data_id)) + conn.sendall(serialized_payload) + + +def receive_data(conn): + """ + @brief: receive data from the connection assuming that + first 4 bytes represents data size, + next 4 bytes represents data identifier and + successive bytes of the size 'data size'is payload + @args[in]: + conn: socket object for conection from which data is supposed to be received + """ + # receive first 4 bytes of data as data size of payload + data_size = struct.unpack(">I", conn.recv(4))[0] + # receive next 4 bytes of data as data identifier + data_id = struct.unpack(">I", conn.recv(4))[0] + # receive payload till received payload size is equal to data_size received + received_payload = b"" + reamining_payload_size = data_size + while reamining_payload_size != 0: + received_payload += conn.recv(reamining_payload_size) + reamining_payload_size = data_size - len(received_payload) + payload = pickle.loads(received_payload) + return (data_id, payload) + + +# define category in which you would like to define data +data_identifiers = {"info": 0, "data": 1, "image": 2} +# key to be trusted by server +key_message = "C0nn3c+10n" +# a sample dictionary data +data = {"data number": 0, "message": "A new message has been arrived from client"} + + +def main(config): + # create client socket object and connect it to server + conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + conn.connect((config["ip"], config["port"])) + send_data(conn, config["key_message"]) + first_payload = receive_data(conn)[1] + if first_payload == "You are not authorized": + print("[ERROR]: Access denied") + else: + # send a cam data in loop till keyboard interrupt is received + cap = cv2.VideoCapture(0) + if not cap.isOpened(): + print("[ERROR]: Failed to open camera") + conn.close() + sys.exit() + while True: + try: + # send dict + data["data number"] += 1 + send_data(conn, data, config["data_identifiers"]["data"]) + print(receive_data(conn)[1]) + # send image + ret, frame = cap.read() + if not ret: + print("[ERROR]: Failed to read frame") + break + else: + if config["client"]["resize_image"]: + frame = cv2.resize( + frame, + (config["client"]["height"], config["client"]["width"]), + ) + if config["client"]["grayscale"]: + frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + send_data(conn, frame, config["data_identifiers"]["image"]) + print(receive_data(conn)[1]) + except KeyboardInterrupt: + print("\n[INFO]: Keyboard Interrupt received") + # once keyboard interrupt is received, send signal to server for closing connection + send_data(conn, "bye") + # close connection + conn.close() + print("[INFO]: Connection closed") + + +if __name__ == "__main__": + with open("config.yaml", "r") as file: + config = yaml.safe_load(file) + main(config) diff --git a/cam_streaming/config.yaml b/cam_streaming/config.yaml new file mode 100644 index 0000000..44ad844 --- /dev/null +++ b/cam_streaming/config.yaml @@ -0,0 +1,23 @@ +ip: "127.0.0.1" +port: 12345 +# key to trust a connection +key_message: "C0nn3c+10n" +# define identifiers for data which could be used to take certain action for data +data_identifiers: + info: 0 + data: 1 + image: 2 +server: + #if true then visualization of streamed cam without latency will be done + show_normal_cam: True + #if true then visualization of streamed cam with latency will be done + show_cam_with_latency: True + # latency between visualization of two consecutive frame + latency: 0.2 + # maximum number of frames which should be accumulated in buffer before all frames as dropped + cam_buffer_len: 1000 +client: + resize_image: False + resized_width: 512 + resized_height: 512 + grayscale: False \ No newline at end of file diff --git a/cam_streaming/server.py b/cam_streaming/server.py new file mode 100644 index 0000000..0654145 --- /dev/null +++ b/cam_streaming/server.py @@ -0,0 +1,154 @@ +import socket +import threading +import time +import pickle +import cv2 +import struct +import time +import yaml + + +def send_data(conn, payload, data_id=0): + """ + @brief: send payload along with data size and data identifier to the connection + @args[in]: + conn: socket object for connection to which data is supposed to be sent + payload: payload to be sent + data_id: data identifier + """ + # serialize payload + serialized_payload = pickle.dumps(payload) + # send data size, data identifier and payload + conn.sendall(struct.pack(">I", len(serialized_payload))) + conn.sendall(struct.pack(">I", data_id)) + conn.sendall(serialized_payload) + + +def receive_data(conn): + """ + @brief: receive data from the connection assuming that + first 4 bytes represents data size, + next 4 bytes represents data identifier and + successive bytes of the size 'data size'is payload + @args[in]: + conn: socket object for conection from which data is supposed to be received + """ + # receive first 4 bytes of data as data size of payload + data_size = struct.unpack(">I", conn.recv(4))[0] + # receive next 4 bytes of data as data identifier + data_id = struct.unpack(">I", conn.recv(4))[0] + # receive payload till received payload size is equal to data_size received + received_payload = b"" + reamining_payload_size = data_size + while reamining_payload_size != 0: + received_payload += conn.recv(reamining_payload_size) + reamining_payload_size = data_size - len(received_payload) + payload = pickle.loads(received_payload) + return (data_id, payload) + + +def do_something(conn_name, data): + """ + @beief: a sample function to do something with received data + @args[in]: + conn_name: connection name from where dat is received + data: received data + @args[out]: + a string response + """ + print( + "Data number {} received from client {}".format(data["data number"], conn_name) + ) + time.sleep(0.1) + return "Data number {} received on server".format(data["data number"]) + + +def handle_client(conn, conn_name, config): + """ + @brief: handle the connection from client at seperate thread + @args[in]: + conn: socket object of connection + con_name: name of the connection + """ + cam_buffer = [] + timer = time.time() + while True: + data_id, payload = receive_data(conn) + # if data identifier is image then handle the image + if data_id == config["data_identifiers"]["image"]: + # show normal cam + if config["server"]["show_normal_cam"]: + cv2.imshow("normal_stream", payload) + # show cam with latency + if config["server"]["show_cam_with_latency"]: + if len(cam_buffer) > config["server"]["cam_buffer_len"]: + cam_buffer = [] + cam_buffer.append(payload) + current_time = time.time() + if current_time - timer > config["server"]["latency"]: + cv2.imshow("stream_with_latency", cam_buffer[0]) + cam_buffer.pop(0) + cv2.waitKey(1) + timer = current_time + # send response to client + send_data(conn, "Image received on server") + elif data_id == config["data_identifiers"]["data"]: + # otherwise send the data to do something + response = do_something(conn_name, payload) + send_data(conn, response) + else: + # if data is 'bye' then break the loop and client connection will be closed + if payload == "bye": + print("[INFO]: {} requested to close the connection".format(conn_name)) + print("[INFO]: Closing connection with {}".format(conn_name)) + break + else: + print(payload) + conn.close() + cv2.destroyAllWindows() + + +def main(config): + # create server socket + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.bind((config["ip"], config["port"])) + server_socket.listen(5) + print("[INFO]: Server Started") + + while True: + try: + # accept client connection + # if first message from client match the defined message + # then handle it at separate thread + # otherwise close the connection + conn, (address, port) = server_socket.accept() + conn_name = "{}|{}".format(address, port) + print("[INFO]: Accepted the connection from {}".format(conn_name)) + first_payload = receive_data(conn)[1] + if first_payload == config["key_message"]: + print("Connection could be trusted, starting communication") + send_data(conn, "Connection accepted") + threading.Thread( + target=handle_client, + args=(conn, conn_name, config), + ).start() + break + else: + print( + "[WARNING]: Accepted connection is an unknown client, \ + closing the connection" + ) + send_data(conn, "You are not authorized") + conn.close() + # break the while loop when keyboard interrupt is received and server will be closed + except KeyboardInterrupt: + print("\n[INFO]: Keyboard Interrupt Received") + break + server_socket.close() + # print("[INFO]: Server Closed") + + +if __name__ == "__main__": + with open("config.yaml", "r") as file: + config = yaml.safe_load(file) + main(config) From 989d01cc00252d9dbd010e919ecf16f0b1234e20 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 12:10:21 +0200 Subject: [PATCH 02/17] added instruction for launching the script --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index beb5f3b..8d6500d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ ## About A sample socket programming in python using low level networking interface module [socket](https://docs.python.org/3.3/library/socket.html). +## Instructions +* Run server first and then client. +* To close connection, give keyboard interrupt to client, server will close automatically. + ## Features You will find follwing on top of vanilla implementation you find in any first tutorial link you get from googling: * Allowing communication with trusted client only, check using first received message from client as key message From 954bf12972b9ae25da6a5b8e1022099add028d5a Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 12:10:57 +0200 Subject: [PATCH 03/17] commented out misleading print --- client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.py b/client.py index ac2cc2c..4cc747e 100644 --- a/client.py +++ b/client.py @@ -77,7 +77,7 @@ def main(): send_data(conn, "bye") # close connection conn.close() - print("[INFO]: Connection closed") + # print("[INFO]: Connection closed") if __name__ == "__main__": From faa0ef82c6fb749304b1cb4cbeb59da82b8903ea Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 12:12:23 +0200 Subject: [PATCH 04/17] added todo --- docs/TODO.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 docs/TODO.md diff --git a/docs/TODO.md b/docs/TODO.md new file mode 100644 index 0000000..15ca15e --- /dev/null +++ b/docs/TODO.md @@ -0,0 +1,2 @@ +# TODO +* Neat server socket closing. \ No newline at end of file From 74ed6a630ca85879bdf50b10d984df5f82a55846 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 12:42:40 +0200 Subject: [PATCH 05/17] commented out misleading print --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index ae2343a..3a1e462 100644 --- a/server.py +++ b/server.py @@ -137,7 +137,7 @@ def main(): break server_socket.close() - print("[INFO]: Server Closed") + # print("[INFO]: Server Closed") if __name__ == "__main__": From 57ff28abdb228b19363539967caba7a904b1bf63 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:30:41 +0200 Subject: [PATCH 06/17] removed the code not required for image transfer --- cam_streaming/client.py | 14 +------------- cam_streaming/server.py | 20 -------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/cam_streaming/client.py b/cam_streaming/client.py index 791e15d..27c393a 100644 --- a/cam_streaming/client.py +++ b/cam_streaming/client.py @@ -45,14 +45,6 @@ def receive_data(conn): return (data_id, payload) -# define category in which you would like to define data -data_identifiers = {"info": 0, "data": 1, "image": 2} -# key to be trusted by server -key_message = "C0nn3c+10n" -# a sample dictionary data -data = {"data number": 0, "message": "A new message has been arrived from client"} - - def main(config): # create client socket object and connect it to server conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -70,10 +62,6 @@ def main(config): sys.exit() while True: try: - # send dict - data["data number"] += 1 - send_data(conn, data, config["data_identifiers"]["data"]) - print(receive_data(conn)[1]) # send image ret, frame = cap.read() if not ret: @@ -88,7 +76,7 @@ def main(config): if config["client"]["grayscale"]: frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) send_data(conn, frame, config["data_identifiers"]["image"]) - print(receive_data(conn)[1]) + # print(receive_data(conn)[1]) except KeyboardInterrupt: print("\n[INFO]: Keyboard Interrupt received") # once keyboard interrupt is received, send signal to server for closing connection diff --git a/cam_streaming/server.py b/cam_streaming/server.py index 0654145..45cb86d 100644 --- a/cam_streaming/server.py +++ b/cam_streaming/server.py @@ -47,22 +47,6 @@ def receive_data(conn): return (data_id, payload) -def do_something(conn_name, data): - """ - @beief: a sample function to do something with received data - @args[in]: - conn_name: connection name from where dat is received - data: received data - @args[out]: - a string response - """ - print( - "Data number {} received from client {}".format(data["data number"], conn_name) - ) - time.sleep(0.1) - return "Data number {} received on server".format(data["data number"]) - - def handle_client(conn, conn_name, config): """ @brief: handle the connection from client at seperate thread @@ -92,10 +76,6 @@ def handle_client(conn, conn_name, config): timer = current_time # send response to client send_data(conn, "Image received on server") - elif data_id == config["data_identifiers"]["data"]: - # otherwise send the data to do something - response = do_something(conn_name, payload) - send_data(conn, response) else: # if data is 'bye' then break the loop and client connection will be closed if payload == "bye": From b84624858279d1cb2826c0d47c459e3396e707ff Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:34:12 +0200 Subject: [PATCH 07/17] added comment --- cam_streaming/server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cam_streaming/server.py b/cam_streaming/server.py index 45cb86d..1bff519 100644 --- a/cam_streaming/server.py +++ b/cam_streaming/server.py @@ -53,6 +53,7 @@ def handle_client(conn, conn_name, config): @args[in]: conn: socket object of connection con_name: name of the connection + config: configuration """ cam_buffer = [] timer = time.time() From a06702e1655e66a3befc605cd789c794e3f02ea8 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:36:34 +0200 Subject: [PATCH 08/17] todo updated --- docs/TODO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/TODO.md b/docs/TODO.md index 15ca15e..055f4b3 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -1,2 +1,2 @@ # TODO -* Neat server socket closing. \ No newline at end of file +* catching keyboard interrupt is not working in server.py. For now as a workaround break is added to while loop after connecting with a client. Need to be fixed. \ No newline at end of file From 1a3873af36e3465f37783bef9b8447d2c98ad8ea Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:37:09 +0200 Subject: [PATCH 09/17] todo updated --- cam_streaming/client.py | 2 +- docs/TODO.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cam_streaming/client.py b/cam_streaming/client.py index 27c393a..da982bc 100644 --- a/cam_streaming/client.py +++ b/cam_streaming/client.py @@ -83,7 +83,7 @@ def main(config): send_data(conn, "bye") # close connection conn.close() - print("[INFO]: Connection closed") + # print("[INFO]: Connection closed") if __name__ == "__main__": diff --git a/docs/TODO.md b/docs/TODO.md index 055f4b3..9202194 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -1,2 +1,3 @@ # TODO -* catching keyboard interrupt is not working in server.py. For now as a workaround break is added to while loop after connecting with a client. Need to be fixed. \ No newline at end of file +* catching keyboard interrupt is not working in server.py. For now as a workaround break is added to while loop after connecting with a client. Need to be fixed. +* close client in a neat way. \ No newline at end of file From ba02d4639030a11d3336a61f40e9619bb176befe Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:43:47 +0200 Subject: [PATCH 10/17] image resize fix --- cam_streaming/client.py | 5 ++++- cam_streaming/config.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cam_streaming/client.py b/cam_streaming/client.py index da982bc..01e6d4f 100644 --- a/cam_streaming/client.py +++ b/cam_streaming/client.py @@ -71,7 +71,10 @@ def main(config): if config["client"]["resize_image"]: frame = cv2.resize( frame, - (config["client"]["height"], config["client"]["width"]), + ( + config["client"]["resized_width"], + config["client"]["resized_height"], + ), ) if config["client"]["grayscale"]: frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) diff --git a/cam_streaming/config.yaml b/cam_streaming/config.yaml index 44ad844..bc7f1a8 100644 --- a/cam_streaming/config.yaml +++ b/cam_streaming/config.yaml @@ -18,6 +18,6 @@ server: cam_buffer_len: 1000 client: resize_image: False - resized_width: 512 + resized_width: 1024 resized_height: 512 grayscale: False \ No newline at end of file From 656946c9a9242f6e935e3a4e9f9e67ebb13d265d Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:47:33 +0200 Subject: [PATCH 11/17] added conda env export --- conda_env_export.yml | Bin 0 -> 3526 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 conda_env_export.yml diff --git a/conda_env_export.yml b/conda_env_export.yml new file mode 100644 index 0000000000000000000000000000000000000000..2f72bbf770a8a70118b98b192cd598665e53f943 GIT binary patch literal 3526 zcmb7{+iu!e6o&V8rFnT1 zBezYrNOaPY-+NGtnuOTdg`7Go^ewVWzCNP)h;G06ZpW!suk*C#er;EabH40BuFV$EC+BGPh18lH!KM zCOUApWTYS`eeP4f*Kr4IcCfi2`zv&8$y*0aGwusCMApXW8)SVG-VX6aFUqSpR-lg5 zVgX)G?OQaM!7&*ha9v($xI^zU+X~B(hlr#gf(dA&nG(-sB-Y*d9pL++o! z_j2W%nGpYooL*Ts5pu*jS2b%|++xda=)m~ks@1Qo%N#uj>jV5&+nB8N@l#JchqWla zWj(UTJnMrwTJqbdyWr~e+vFV2kqnNDFuxd0%33WZ^oSjq9-{+ zV?3CXrvdqqfo;CV#6J>iNjEG{{yIggIp#EV-VQS}+qJ|b7VQiia8@0teWzI4EDGWA3guu3B}ATNvWJ zdpTLOCczTl^+Dc&xaF<$$f%oLT}{n-?kl+>U**bKgR^&-J73;Tsr}{DuQVKB%LZIb z!Sg!bta^QV?#PyFm6Ol7V}*O0WjmO;0};ClBX*s=^!Kfug>pyo;w%YowOo)LXPE2S z3_oJm(&YCgc8Z)mQt8m2Dbeh5-Y+vG>IG>zdDD{LW`^oD{(-k0urqAwvAta6Ypjq9 zGPmH_**wC7QLQ?Gj;?Yy75fYGeby7RDKr%LR}w{=p3riSANGd$9-f33RSYG$b8l7W zi2Il$T-|Z~&f)IWOqhB3-sIa`^*f{=;Pt^MVlKy=`R_I8>C~ICFAVvDu2^Q~>32Q% zPxvVl%(wfRM>6PSbzfzVhn`W+#3aiNdGAiqij48ju50$(PbA!F%7&Qg!TtAh_&L3T zwF2iz-dkilbi2LTtevb97;?)R_*@>>H{=ZqL=lmb*Pp)6n jUwG;M_`q-b;tA<{wC{QTbh6|Bsjo=6?@;dd|IYpagNWQX literal 0 HcmV?d00001 From 224fa8c91a3cf19249ac6008f109f4724397681d Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:50:15 +0200 Subject: [PATCH 12/17] updated readme for conda environment --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8d6500d..b6f7440 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ A sample socket programming in python using low level networking interface module [socket](https://docs.python.org/3.3/library/socket.html). ## Instructions +* Create conda environment with required dependedncies by running: + ```bash + conda create --name socket_prog --file conda_env_export.yml + ``` * Run server first and then client. * To close connection, give keyboard interrupt to client, server will close automatically. From 028157e7318e4d68e66f26efb29f149e92b41e8a Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:51:53 +0200 Subject: [PATCH 13/17] linting --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b6f7440..6d0f58f 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,37 @@ # Python Socket Programming +

drawing

## About + A sample socket programming in python using low level networking interface module [socket](https://docs.python.org/3.3/library/socket.html). ## Instructions + * Create conda environment with required dependedncies by running: + ```bash conda create --name socket_prog --file conda_env_export.yml ``` + * Run server first and then client. * To close connection, give keyboard interrupt to client, server will close automatically. ## Features + You will find follwing on top of vanilla implementation you find in any first tutorial link you get from googling: + * Allowing communication with trusted client only, check using first received message from client as key message * Multithreading to handle multiple clients -* Use of pickel to serialize any type of data +* Use of pickel to serialize any type of data * Handling of variable length data by passing payload size along with payload * Passing data identifier with payload as additional information to take specific action accordingly (eg. if data identifier is image then save payload as image) * Using keyboard interrupt to close client and server cleanly ## Notes -* Program is wrtten in python 3.7.4 +* Program is wrtten in python 3.7.4 -> *** Feel free to request more feature you would like, i wil try to add it when i get time *** - +> ***Feel free to request more feature you would like, i wil try to add it when i get time*** \ No newline at end of file From 668efea07de40da5979089d90a803e6c11e30ec3 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:52:19 +0200 Subject: [PATCH 14/17] typo fi --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d0f58f..3ec1889 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ ## About -A sample socket programming in python using low level networking interface module [socket](https://docs.python.org/3.3/library/socket.html). +A sample socket programming in python using low level networking interface module [socket](https://docs.python.org/3.3/library/socket.html). ## Instructions -* Create conda environment with required dependedncies by running: +* Create conda environment with required dependencies by running: ```bash conda create --name socket_prog --file conda_env_export.yml @@ -32,6 +32,6 @@ You will find follwing on top of vanilla implementation you find in any first tu ## Notes -* Program is wrtten in python 3.7.4 +* Program is written in python 3.7.4 > ***Feel free to request more feature you would like, i wil try to add it when i get time*** \ No newline at end of file From b5eb63ff17186546dc91a5950d2eb4cedfde13b9 Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:54:01 +0200 Subject: [PATCH 15/17] added comment --- cam_streaming/config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cam_streaming/config.yaml b/cam_streaming/config.yaml index bc7f1a8..7df1c8a 100644 --- a/cam_streaming/config.yaml +++ b/cam_streaming/config.yaml @@ -16,8 +16,13 @@ server: latency: 0.2 # maximum number of frames which should be accumulated in buffer before all frames as dropped cam_buffer_len: 1000 + client: + # if True then image from cam will be resized before sending resize_image: False + # width of the resized image resized_width: 1024 + # height of the resized image resized_height: 512 + # if true the cam image will be converted to grayscale before sending grayscale: False \ No newline at end of file From 581e048358cf428d5c71e23d4816d0f4c00ec8eb Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 13:56:58 +0200 Subject: [PATCH 16/17] updated read me about cam_streaming --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3ec1889..4244672 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ A sample socket programming in python using low level networking interface module [socket](https://docs.python.org/3.3/library/socket.html). +Inside 'cam_streaming' directory one could the variant of client and server script which reads the cam data and on client side and send it to server. Then server could show up to two stream for received cam images. Among the two stream, for one stream latency could be added. Check config file inside cam_streaming directory to set the configuration. + ## Instructions * Create conda environment with required dependencies by running: From c04e8f407c8e00db7c89425352c6f8b1cb3b5a3a Mon Sep 17 00:00:00 2001 From: "Singh Vijendra (BEG/EOR2)" Date: Mon, 28 Aug 2023 14:56:34 +0200 Subject: [PATCH 17/17] readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4244672..d8481e9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Inside 'cam_streaming' directory one could the variant of client and server scri * Create conda environment with required dependencies by running: ```bash - conda create --name socket_prog --file conda_env_export.yml + conda env create --name socket_prog --file conda_env_export.yml ``` * Run server first and then client.