1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
3 @page image_usecase2 Image Streamer
6 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
8 This tutorial demonstrates how to stream an image from host (CPU) memory, to device (CUDA) memory.<br>
10 The ImageStreamer module is accessed through a handle:
13 dwImageStreamerHandle_t streamerCPU2CUDA = DW_NULL_HANDLE;
15 @section image_usecase2_creating_image Creating an Image
17 To create an image for streaming:
20 // the image is going to be format interleaved RGB and type UINT_8
21 dwImageProperties cpuProp{};
22 cpuProp.type = DW_IMAGE_CPU;
23 cpuProp.width = imageWidth;
24 cpuProp.height = imageHeight;
25 cpuProp.format = DW_IMAGE_FORMAT_RGB_UINT8;
26 cpuProp.memoryLayout = DW_IMAGE_MEMORY_TYPE_DEFAULT; // not necessary to specify if init with {}
28 //Create an image with these properties
29 dwImageHandle_t rgbCPU;
30 dwImage_create(&rgbCPU, cpuProp, m_context);
33 @section image_usecase2_initialize Initializing the ImageStreamer Module
35 Once an image is creating for streaming, an ImageStreamer must be initialized to stream the CPU image to CUDA.<br>
36 In the following example, the ::dwImageStreamerHandle_t handle initializes the ImageCapture module to stream <br> an image with `cpuProp` image properties to type ::dwImageCUDA:
39 // streamer from CPU to CUDA
40 dwImageStreamerHandle_t streamerCPU2CUDA = DW_NULL_HANDLE;
42 dwImageStreamer_initialize(streamerCPU2CUDA, &cpuProp, DW_IMAGE_CUDA, dwContext);
45 @section image_usecase2_streaming_image Streaming the Image
50 dwImageStreamer_producerSend(rgbCPU,streamerCPU2CUDA);
51 dwImageHandle_t rgbCUDA;
52 dwImageStreamer_consumerReceive(&rgbCUDA,streamerCPU2CUDA);
55 @section image_usecase2_return Returning the Images
57 An image must be returned once streaming to CUDA memory is complete:
60 dwImageStreamer_consumerReturn(rgbCUDA,streamerCPU2CUDA);
61 dwImageStreamer_producerReturn(rgbCPU,streamerCPU2CUDA);
64 @section image_usecase2_releasing_handle Releasing the Handle
66 To release the handle:
69 dwImageStreamer_release(streamerCPU2CUDA);
72 To see a full demonstration of this workflow, please refer to @ref dwx_image_streamer_simple_sample.