Exporting CVB images to stream/buffer

Hi all

Our software produces a data file in a streaming fashion in which we save a series of images among other things. It is therefore necessary for us to export the images acquired through CVB as bmp images or similar image format that can be read by other software (without a dependency on CVB).

We have noticed that there is a function WriteImageFile, which writes the image with complete headers to disk.
However, since the function writes the data directly to a file given by name, it is too limited for our purposes. The images need to be passed around within the program and eventually written as part of this combined data file so what we are looking for is a way to export the same data but into a buffer in memory.

Any help with how to do that is much appreciated.

Hi @ChristianGE
you can use LinearAccess to get the actual data behind the image and then either write this into an array for forther processing or copy it to another image.
Also there should be a CVWebstreaming.dll in your CVB installation if all you want to do is stream converted image data:

CVB Webstreaming doc


Hi @Chris
Thanks for your reply. We have been using the GetLinearAccess function for now but it has a couple of drawbacks that makes it ill-suited for our usecase. The order of the image planes is not stable and it depends on the camera configuration and prohibits us from using alternative formats for transfer such as BayerRG8.
The order of the planes also makes for some confusing cases, e.g. when transferring the image in BGR order to facilitate making a bmp image, the first pixel starts on plane 2, which is highly unintuitive.

We have also tried using the ImageToMemoryRaw function. It outputs the raw pixel values, which seems good but it only outputs as RGB and seems to be flipped vertically compared to the buffer of GetLinearAccess so it is hard to know, what the correct use is. It also does additional allocation compared to LinearAccess.

Best regards,

Even if it is late, I want to add some information here.
The purpose of GetLinearAccess is to give you linear access to the existing memory without copying any data.
Our goal with CVB is always to avoid copying data if possible. Meaning, if the incoming PixelFormat is supported by CVB we do not copy the data. Therefore, it is clear that the order of the image planes depends on the camera configuration.
The BGR pixel format for example is an interleaved format and has the first red pixel on the third position. This is what you see.

As this source format is not directly compatible with a bitmap file, the data is copied within the SaveImageFile call.
By the way: a Bitmap is vertically flipped compared to the camera source formats. If you reopen a bitmap file you will have a negative y-Increment when accessing the data with GetLinearAccess.