-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebcam-client.py
More file actions
36 lines (28 loc) · 769 Bytes
/
webcam-client.py
File metadata and controls
36 lines (28 loc) · 769 Bytes
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
from configparser import Interpolation
import cv2
import socket
import pickle
#port and address of server
port = 8084
dest = "192.168.246.66"
#object Socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#connect in server
print(f"-- Connecting to {dest} --")
client.connect((dest, port))
#receive date of server
data = []
while True:
pacote = client.recv(4096)
if not pacote: break
data.append(pacote)
#dispack the frame received
frame = pickle.loads(b"".join(data))
client.close()
while True:
cv2.imshow("Input",frame)#show in a window
c= cv2.waitKey(1)#receive a keyboard key typed
if c == 27:#if the keyboard key is ESC, leave to while (BREAK)
break
#When to leave while
cv2.destroyAllWindows()# close all windows