DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

Image Streamer Multi-Thread

In addition to using the ImageStreamer module in a single thread, you can also use it across multiple threads.

This workflow is similar to the single thread case since the same APIs are thread safe.
For details on how to stream an image from CPU to CUDA memory, please refer to
Image Streamer. All other details are left out of this tutorial for simplicity.

Initializing the ImageStreamer Module in Thread A

In the following example, the ImageStreamer is initialized in Thread A before it is used to send images:

// Thread A:
// streamer from CPU to CUDA
dwImageStreamer_initialize(streamerCPU2CUDA, &cpuProp, DW_IMAGE_CUDA, dwContext);
while(true)
{
// CODE: Get an image to stream
dwImageStreamer_producerSend(imgCPU, streamerCPU2CUDA);
dwImageStreamer_producerReturn(nullptr, TIMEOUT, streamerCPU2CUDA);
}

Retrieving the Output from Thread B

After sending the images from Thread A, retrieve the output from Thread B:

// Thread B:
while(true)
{
dwImageStreamer_consumerReceive(&imageCuda, TIMEOUT, streamerCPU2CUDA);
// CODE: Use the streamed image
dwImageStreamer_consumerReturn(&imageCuda, streamerCPU2CUDA);
}

Releasing the Handle

dwImageStreamer_release(...);

To see a full demonstration of this workflow, please refer to Multi-Thread Image Streamer Sample.