Is running data streams of a multispectral camera in threads thread safe?

Dear Team,
I am running my SW4000 line scan camera using multi threading. The camera gives out two streams DS0 (RGB) and DS1 (NIR). I am opening the device and getting the stream pointers and image stream using CVB++. Now, if I start the streams in two separate threads by the NIR stream always crashes for some reason. At lower resolutions, the streams give output as expected but at higher resolutions, once the RGB stream starts giving the output, the NIR stream crashes. So, it is allowed to run these streams separately in threads ? Are they thread safe ?

Hi @keerthitheja,

yes different streams can be handled in different threads. Please check where the crash occurs. If happens inside one of our dlls or the CVB++ headers please contact support and send us a crashdump.



Hi @Andreas
So, I tried to dump the crash using exception, the program mostly crashes at Stream->Wait(). The exception it gives me always is the composite is not an image. This exception mostly occurs only for the NIR stream.

Now that I am handling the exception, I am skipping that particular image and reading out the image acquired on the next trigger.

Hi @keerthitheja

Ok there is an exception thrown so this is not a crash but your responsibility to catch and handle it.
By the way stating the message from exception helps a lot!

Anyway, the reason for the exception could still be an issue our side. We just recently fixed a bug that caused such an exception. Please update to the most recent CVB version. If there is still an exception please tell me the pixel format of the NIR stream.


Hi @Andreas
So, I downloaded the latest release of 14.00.000 of CVB from the below link and installed it on my PC

With this package, my code fails to compile. It throws an error while accessing the stream pointer using the line
device->Stream<Cvb::ImageStream>(). The error it says is Stream expects an expression but got a type. But, if I look in the CVB++ documentation, the stream is defined to take types

Is the function Stream updated in the latest release ? or Am i missing something ? Please let me know how to go about this

Note: Now, I reverted back my CVB version to 13.04.006 and the code compiles fine.

Yes, unfortunatelly we did not update the online reference yet. The local documentation is correct. We have moved Stream<T> to the GenICamDevice as it as the only device supporting it. In order to get a GenICamDevice use auto device = Cvb::DeviceFactory::Open<Cvb::GenICamDevice>(...)

Sorry for the inconvenience.

CVB 13.04.06 should also include the fix mentioned above.

1 Like

Hi @Andreas
Thank you for the reply. so the issue I had highlighted here below was seen with the version 13.04.006 of CVB.

I am having difficulty in setting the pixel format for each stream individually using CVB++.

Setting the pixel format is via the CVB device nodemap and with this, I can either set it to RGB8 or Mono before I start the streams.

Is it possible to set the pixel format for each stream individually ?
For more understanding of my problem, please refer to the below thread

You can set the pixel format of the streams in the device, respectively the device node map. This might be confusing as the streams also have node map but that is not the right one. If you want to change properties on the (remote) device streams you have to select the stream in the (remote) device node map first.

Some background information:

The GenTL architecture defines different modules each one can expose properties to the user via an XML that is interpreted by the GenAPI. The device is the only module that has two representaions, These modules include:

  • TL/System: refers to the binary the *.cti file itself.
  • Interface: The Grabber or NIC or USB HC
  • TLDevice: The device as seen from inside the GenTL. Usually contains properties of the acquisition engine.
  • (Remote) Device: The physical device (camera). It may contains multiple streams but they do not get an extra interface.
  • Stream The streams as known by the GenTL, Only referring to acquisition engine properties.
  • Buffer Individual buffers for acquisition