-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.py
More file actions
20 lines (18 loc) · 1.03 KB
/
Copy pathtest_server.py
File metadata and controls
20 lines (18 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import cv2, socket, numpy, pickle # Import Modules
# AF_INET refers to the address of family of ip4v
# SOCK_DGRAM means connection oriented UDP protocol
s=socket.socket(socket.AF_INET , socket.SOCK_DGRAM) # Gives UDP protocol to follow
ip="192.168.127.114" # Server public IP
port=2323 # Server Port Number to identify the process that needs to recieve or send packets
s.bind((ip,port)) # Bind the IP:port to connect
# In order to iterate over block of code as long as test expression is true
while True:
x=s.recvfrom(100000000) # Recieve byte code sent by client using recvfrom
clientip = x[1][0] # x[1][0] in this client details stored,x[0][0] Client message Stored
data=x[0] # Data sent by client
data=pickle.loads(data) # All byte code is converted to Numpy Code
data = cv2.imdecode(data, cv2.IMREAD_COLOR) # Decode
cv2.imshow('my pic', data) # Show Video/Stream
if cv2.waitKey(10) == 13: # Press Enter then window will close
break
cv2.destroyAllWindows()