1 # Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
3 @page image_usecase4 Image Streamer Multi-Thread
6 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
8 In addition to using the ImageStreamer module in a [single thread](@ref image_usecase2), you can also use it across multiple threads.
10 This workflow is similar to the single thread case since the same APIs are thread safe.<br>
11 For details on how to stream an image from CPU to CUDA memory, please refer to \n @ref image_usecase2. All other details are left out of this tutorial for simplicity.
13 @section image_usecase4_threadA Initializing the ImageStreamer Module in Thread A
15 In the following example, the ImageStreamer is initialized in Thread A before it is used to send images:
19 // streamer from CPU to CUDA
20 dwImageStreamerHandle_t streamerCPU2CUDA = DW_NULL_HANDLE;
22 dwImageStreamer_initialize(streamerCPU2CUDA, &cpuProp, DW_IMAGE_CUDA, dwContext);
25 // CODE: Get an image to stream
26 dwImageStreamer_producerSend(imgCPU, streamerCPU2CUDA);
27 dwImageStreamer_producerReturn(nullptr, TIMEOUT, streamerCPU2CUDA);
31 @section image_usecase4_retrieving_output Retrieving the Output from Thread B
33 After sending the images from Thread A, retrieve the output from Thread B:
39 dwImageStreamer_consumerReceive(&imageCuda, TIMEOUT, streamerCPU2CUDA);
40 // CODE: Use the streamed image
41 dwImageStreamer_consumerReturn(&imageCuda, streamerCPU2CUDA);
45 @section image_usecase4_releasing_handle Releasing the Handle
48 dwImageStreamer_release(...);
51 To see a full demonstration of this workflow, please refer to @ref dwx_image_streamer_multi_sample.