This is my code snippet that sends data over ethernet from one PC to another which is working fine.
import cv2, socket, pickle
import numpy as np
while True:
ret, photo = cap.read()
ret, buffer = cv2.imencode(".jpg",photo, [int(cv2.IMWRITE_JPEG_QUALITY),30])
x_as_bytes = pickle.dumps(buffer)
socket.sendto((x_as_bytes),(server_ip,server_port))
At the receiver end, I am not able to decode it. It says:
Traceback (most recent call last):
File "receive.py", line 12, in <module>
data=pickle.loads(data)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
This is the snippet at the receiver end
while True:
x=s.recvfrom(1000000)
clientip = x[1][0]
data=x[0]
print(data)
data=pickle.loads(data) #ERROR IN THIS LINE
print(type(data))
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
cv2.imshow('server', data)
if cv2.waitKey(10) == 13:
break