I ran into a problem while trying to stream images over a local network. On the system with the camera I can see the images perfectly fine and I can establish a socket between the two computers. I want to send the data as a StringIO
to attach the size of the current image in the String.
However my computer tells me, it cannot convert a np array
to a str
.
Instead I sent it as a BytesIO
, but the client cannot reconvert this data.
Is there a way to send the iages as a StringIO
or to reconvert the BytesIO
?
I forgot to encode correctly, as furas pointed out. I had to add the size as a header via header = '{0}:'.format(packet_size)
, header = bytes(header.encode())
and out += header
.
I modeled my approach after this project: https://github.com/sabjorn/NumpySocket
furas's way should work as well, but my approach was closer to the previously mentioned project.