-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
46 lines (32 loc) · 1.02 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import socket as s
import cv2
import pickle
import struct
server_s = s.socket(s.AF_INET,s.SOCK_STREAM)
host_name = s.gethostname()
host_ip = s.gethostbyname(host_name)
print('HOST IP:',host_ip)
port = 1234
s_address = ('192.168.70.120',port)
print("Socket Created Successfully")
server_s.bind(s_address)
print("Socket Bind Successfully")
server_s.listen(5)
print("LISTENING AT:",s_address)
print("Socket Accept")
while True:
client_s,addr = server_s.accept()
print('GOT CONNECTION FROM:',addr)
if client_s:
vid = cv2.VideoCapture(0)
while(vid.isOpened()):
img,frame = vid.read()
a = pickle.dumps(frame)
message = struct.pack("Q",len(a))+a
client_s.sendall(message)
cv2.imshow('TRANSMITTING VIDEO',frame)
key = cv2.waitKey(1) & 0xFF
if key ==ord('q'):
client_s.close()
print("THANK YOU GUYS ")
print("Created By KRUSHNA PRASAD SAHOO")