DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

Image Streamer

This tutorial demonstrates how to stream an image from host (CPU) memory, to device (CUDA) memory.

The ImageStreamer module is accessed through a handle:

Creating an Image

To create an image for streaming:

// the image is going to be format interleaved RGB and type UINT_8
cpuProp.type = DW_IMAGE_CPU;
cpuProp.width = imageWidth;
cpuProp.height = imageHeight;
cpuProp.format = DW_IMAGE_FORMAT_RGB_UINT8;
cpuProp.memoryLayout = DW_IMAGE_MEMORY_TYPE_DEFAULT; // not necessary to specify if init with {}
//Create an image with these properties
dwImage_create(&rgbCPU, cpuProp, m_context);

Initializing the ImageStreamer Module

Once an image is creating for streaming, an ImageStreamer must be initialized to stream the CPU image to CUDA.
In the following example, the dwImageStreamerHandle_t handle initializes the ImageCapture module to stream
an image with cpuProp image properties to type dwImageCUDA:

// streamer from CPU to CUDA
dwImageStreamer_initialize(streamerCPU2CUDA, &cpuProp, DW_IMAGE_CUDA, dwContext);

Streaming the Image

To stream the image:

dwImageStreamer_producerSend(rgbCPU,streamerCPU2CUDA);
dwImageStreamer_consumerReceive(&rgbCUDA,streamerCPU2CUDA);

Returning the Images

An image must be returned once streaming to CUDA memory is complete:

dwImageStreamer_consumerReturn(rgbCUDA,streamerCPU2CUDA);
dwImageStreamer_producerReturn(rgbCPU,streamerCPU2CUDA);

Releasing the Handle

To release the handle:

dwImageStreamer_release(streamerCPU2CUDA);

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