我有一张图片已经使用protobuf进行编码,并像下面这样发送出去:
message.image = numpy.ndarray.tobytes(image)
当我接收并解析该消息时,我使用以下代码:
image_array = numpy.frombuffer(request.image, numpy.uint8)
这给了我一个一维数组,但我无法将其转换为图像格式。我曾尝试使用numpy的reshape命令,但未成功:
image = image_array.reshape( 400, 600, 3 )
发送的图像大小为400x600像素,是一个三通道的彩色图像。您有什么建议吗?
np.reshape
吗? - ZdaR