Serializing image stream using protobuf

If I had to do this, I would use one of:

message image {
    int width = 1;
    int height = 2;
    bytes image_data = 3;
}

message image {
    int width = 1;
    int height = 2;
    bytes red_data = 3;
    bytes green_data = 4;
    bytes blue_data = 5;
}

Or possibly use an intermediate ScanRow message, composed either of interleaved R, G, B bytes or separated R, G, B bytes. The first version is likely going to be fastest to generate and display.


According to this blog post : https://medium.com/@brynmathias/kafka-and-google-protobuf-a-match-made-in-python-a1bc3381da1a

you could use the following schema :

syntax = 'proto3';

package protobuf.data;
import "protobuf/common/messageData.proto";

message Image {
    bytes image_data = 1;
    int32 height = 2;
    int32 width = 3;
    int64 frame = 4;
    protobuf.common.messageData _message_data = 5;

}