I have a requirement to get the VideoFrame.SoftwareBitMap
from the Windows.Media.VideoFrame
in C# and then convert this SOftwareBitmap
to a ByteArray and then send the ByteArray using ZeroMQ to Python (using ZMQ) using TCP socket connection.
I am receiving the Bytearray from C# to Python but i am not able to convert this ByteArray in Python to an image . I have tried the below code in python -
message = socket.recv_multipart() print('message2 received' ,message[2]) img = cv2.imdecode(message[2], -1)
message[2] is the entire bytearray.
I receive the below error on the cv2.imdecode line -
TypeError: buf is not a numpy array, neither a scalar
Please advise what am i doing wrong ?
Example of the ByteArray (some part) received -
14\x1d\xff\n\x13\x1c\xff\n\x14\x1b\xff\t\x13\x1a\xff\x06\x11\x15\xff\x08\x13\x17\xff\x07\x13\x15\xff\x0c\x15\x18\xff\x0e\x17\x1a\xff\r\x14\x17\xff\x0e\x15\x18\xff\x12\x17\x1a\xff\x10\x14\x19\xff\x12\x14\x1c\xff\x12\x15\x1d\xff\x11\x16\x1f\xff\x0e\x17!\xff\x0c\x18$\xff\x0c\x18$\xff\x0c\x18"\xff\x0c\x19!\xff\x15\x1e\'\xff\x18 \'\xff\x19\x1f$\xff\x1f%,\xff\x1f$-\xff\x1e%.\xff!*4\xff\x1c%3\xff\x1e\';\xff#+B\xff&.E\xff&.E\xff#.D\xff!,B\xff\x1f*@\xff\x1e)?\xff (?\xff\x1e\';\xff %:\xff!\':\xff#%7\xff!#5\xff""2\xff$$2\xff\x1f *\xff\x17\x1a\x1f\xff\x17\x18\x1c\xff\x13\x15\x16\xff\x0e\r\x0f\xff\x07\x07\x07\xff\x00\x00\x00\xff\x01\x03\x03\xff\x04\x03\x05\xff\x01\x00\x02\xff\x04\x00\x03\xff\x06\x00\x02\xff\r\x00\x02\xff\x11\x01\x02\xff\x17\x03\x02\xff\x1a\x05\x03\xff\x18\x05\x00\xff\x19\x06\x00\xff\x1f\x08\x00\xff$\x08\x01\xff)\n\x01\xff.\n\x02\xff0\x0c\x02\xff0\r\x03\xff-\x0b\x05\xff%\t\x02\xff\x1b\x05\x00\xff\x10\x01\x00\xff\t\x00\x00\xff\x04\x00\x00\xff\x00\x00\x01\xff\x00\x00\x01\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x01\x01\x01\xff\x01\x01\x01\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\
Many Thanks, Prakhar