11-2VideoReceiver.py

000: import socket
001: import cv2
002: import pickle
003:
004: if __name__ == ‘__main__’:
005:
006: HOST = ‘192.168.101.27’
007: PORT = 2000
008: BUFFER_SIZE = 4096
009: ADDRE = (HOST, PORT)
010:
011: for num in range(1000):
012: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as socketTCP:
013: socketTCP.connect(ADDRE)
014: fullData = b”
015: data = b”
016: while True:
017: data = socketTCP.recv(BUFFER_SIZE)
018: if len(data) <= 0: 019: break 020: 021: fullData += data 022: print('Data = {}'.format(len(fullData))) 023: img = pickle.loads(fullData) 024: cv2.imshow('VideoStream', img) 025: if cv2.waitKey(1) != -1: 026: break 027: 028: cv2.destroyAllWindows()