Decoding Image from Protobuf using Python

Viewed 4954

I have an image that I have encoded and sent out using protobuf like so:

message.image = numpy.ndarray.tobytes(image)

when I receive and parse that message I use this:

image_array = numpy.frombuffer(request.image, numpy.uint8)

This gives me a one-dimensional array. I cannot get this back into an image format. I have tried using numpy's reshape command like so but with no luck:

image = image_array.reshape( 400, 600, 3 )

The image being sent is 400x600 pixels and it is a 3 channel color image. Any suggestions on what I am missing?

1 Answers
Related