Serializing image stream using protobuf
<p>I have two programs in Ubuntu: a C++ program (TORCS game) and a python program. The C++ program always generates images. I want to transfer these real-time images into python(maybe the numpy.ndarray format). So I think that maybe using Google protobuf to serialize the image to string and send string to python client by ZMQ is a feasible method.</p>

<p><strong>Question</strong>: which value type is suitable for the image(a pointer) in <code>.proto</code> file?  In another words, which value type I should use to replace <code>string</code> type in the below example?</p>

<pre><code>message my_image{
     repeated string image = 1
     }
</code></pre>

<p>This is the way I write image to memory (uint8_t* image_data):</p>

<pre><code>glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
</code></pre>

<p>At last, maybe there is a better way to transfer image (in the memory) to a python client?</p>

<p>Any suggestions are appreciated.</p>

<p>If I had to do this, I would use one of:</p>

<pre><code>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;
}
</code></pre>

<p>Or possibly use an intermediate <code>ScanRow</code> 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.</p>

python c++ protocol-buffers