Loading [MathJax]/jax/input/TeX/config.js
  • <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>

  • DriveWorks SDK Reference
    5.8.83 Release
    For Test and Development only

    All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    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);
    }
    #define DW_NULL_HANDLE
    Definition: Types.h:96
    @ DW_IMAGE_CUDA
    Definition: Image.h:100
    struct dwImageStreamerObject * dwImageStreamerHandle_t
    Definition: ImageStreamer.h:61
    DW_API_PUBLIC dwStatus dwImageStreamer_initialize(dwImageStreamerHandle_t *streamer, const dwImageProperties *from, dwImageType to, dwContextHandle_t ctx)
    Creates and initializes the image streamer capable of moving images between different API types.
    DW_API_PUBLIC dwStatus dwImageStreamer_producerReturn(dwImageHandle_t *const image, dwTime_t const timeoutUs, dwImageStreamerHandle_t const streamer)
    The producer streamer waits for the image sent to be returned by the consumer.
    DW_API_PUBLIC dwStatus dwImageStreamer_producerSend(dwImageHandle_t image, dwImageStreamerHandle_t const streamer)
    Sends an image through the streamer acting as the producer.

    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);
    }
    DW_API_PUBLIC dwStatus dwImageStreamer_consumerReturn(dwImageHandle_t *image, dwImageStreamerHandle_t const streamer)
    Return the received image back to the producer.
    DW_API_PUBLIC dwStatus dwImageStreamer_consumerReceive(dwImageHandle_t *image, dwTime_t const timeoutUs, dwImageStreamerHandle_t const streamer)
    Receive a pointer to a dwImageHandle_t from the streamer, acting as a consumer.

    Releasing the Handle

    dwImageStreamer_release(...);

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

    人人超碰97caoporen国产