This repository was archived by the owner on Apr 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientVideo.py
More file actions
54 lines (47 loc) · 1.29 KB
/
Copy pathclientVideo.py
File metadata and controls
54 lines (47 loc) · 1.29 KB
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
47
48
49
50
51
52
53
54
import cv2
import numpy as np
import sys
import time
import socket
import pickle
print("[*]Initializing socket for Video")
# video socket
soc=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print("[*]Initializing webcam for Video")
#initilizing webcam for videosocket
video=cv2.VideoCapture(0)
print("[*]Initializtion of webcam access succed\n")
# connecting to video socket at 8080
print("[*] Creating open socket server at 8080 port for video")
soc.connect(('127.0.0.1',8080))
print("[*] Connected \n\n")
def sendVideo():
global soc
while 1:
try:
_,frame=video.read()
img_data=np.array(frame)
data=pickle.dumps(img_data)
soc.send(b'a'+data)
except KeyboardInterrupt:
video.release()
sys.exit()
def recvVideo():
global soc
while 1:
try:
data=b''
length=0
while length<921766:
pac2=soc.recv(9999999)
length+=len(pac2)
data=data+pac2
if data[0:1]==b'b':
frame2=pickle.loads(data[1::])
cv2.imshow("frame2",frame2)
key=cv2.waitKey(1)
if key==27:
break
except KeyboardInterrupt:
sys.exit()
cv2.destroyAllWindows()