Set the Batched Images#

The API takes the image descriptors for only the first image in a batch. The following sample allocates the src and dst batch buffers and sets the input and outputs via the views of the first image in each batch buffer.

Because the image descriptors are copied into the Video Effects SDK, this can be simplified to the following:

NvCVImage srcBatch, dstBatch, nth;
AllocateBatchBuffer(&srcBatch, batchSize, srcWidth, srcHeight,
...);
AllocateBatchBuffer(&dstBatch, batchSize, dstWidth, dstHeight,
...);
NvVFX_SetImage(effect, NVVFX_INPUT_IMAGE,
NthImage(0, srcHeight, &srcBatch, &nth));
NvVFX_SetImage(effect, NVVFX_OUTPUT_IMAGE,
NthImage(0, dstHeight, &dstBatch, &nth));

The other images in the batch are computed by advancing the pixel pointer by the size of each image.

The other aspect of setting the batched images is determining how to set the pixel values. Each image in the batch is accessible by calling the NthImage() function:

NthImage(n, imageHeight, &batchImage, &nthImage);

You can then use the same techniques that were used for other NvCVImage objects on the recently initialized nthImage view. As previously suggested, NthImage() is just a thin wrapper around NvCVImage_InitView() and can be used instead. The NvVFX_Transfer() functions in BatchUtilities.cpp can be used to copy pixels to and from the batch.

Setting the Batch Size for NvVFX_Run()#

By default, the batch size processed by NvVFX_Run() is 1. Before you call NvVFX_Run() to process a batch of any other size, call the following:

NvVFX_SetU32(effect, NVVFX_BATCH_SIZE, batchSize);

As previously noted, there is no connection between the MODEL_BATCH and the BATCH_SIZE, except what the highest performance will be when BATCH_SIZE is an integral multiple of MODEL_BATCH. All images in the submitted batch will be processed.