Image Wrapper classes

group Image Wrapper classes
template<typename T>
class ImageBatchVarShapeWrap
#include <ImageBatchVarShapeWrap.hpp>

Image batch var-shape wrapper class to wrap ImageBatchVarShapeDataStridedCuda.

ImageBatchVarShapeWrap is a wrapper of an image batch (or a list of images) of variable shapes. The template parameter T is the type of each element inside the wrapper, and it can be compound type to represent a pixel type, e.g. uchar4 for RGBA images.

 cudaStream_t stream;
 cudaStreamCreate(&stream);
 nvcv::ImageBatchVarShape imageBatch(samples);
auto *imageBatchData  = imageBatch.exportData<nvcv::ImageBatchVarShapeDataStridedCuda>(stream)
 nvcv::cuda::ImageBatchVarShapeWrap<uchar4> wrap(*imageBatchData);
 // Now wrap can be used in device code to access elements of the image batch via operator[] or ptr method.

Image batch var-shape wrapper class to wrap ImageBatchVarShapeDataStridedCuda.

This class is specialized for non-constant value type.

Note

No accessor in this class bounds-checks the sample index s or the plane index p, and the two fail differently: an out-of-range s reads past the end of the image list, while an out-of-range p below the fixed plane capacity reads unpopulated plane metadata and yields a wild base pointer. Bound both in the caller first. In a kernel guard that means the sample check has to short-circuit ahead of any accessor.

Note

As in the const specialization it derives from, no accessor bounds-checks the sample index s or the plane index p.

Template Parameters:
  • T – Type (it can be const) of each element inside the image batch var-shape wrapper.

  • T – Type (non-const) of each element inside the image batch var-shape wrapper.

Subclassed by nvcv::cuda::ImageBatchVarShapeWrapNHWC< T >

template<typename T>
class ImageBatchVarShapeWrap<const T>
#include <ImageBatchVarShapeWrap.hpp>
template<typename T>
class ImageBatchVarShapeWrapNHWC : private nvcv::cuda::ImageBatchVarShapeWrap<T>
#include <ImageBatchVarShapeWrap.hpp>

Image batch var-shape wrapper NHWC class to wrap ImageBatchVarShapeDataStridedCuda and number of channels.

This class handles number of channels as a separate run-time parameter instead of built-in T. It considers interleaved channels, where they appear in a packed sequence at the last dimension (thus NHWC). It also considers each image in the batch has a single plane.

Note

The class ImageBatchVarShapeWrap can be used with its template parameter T type as a compound type, where its number of elements yield the number of channels.

Note

As in ImageBatchVarShapeWrap, no accessor bounds-checks the sample index s; bound it in the caller first. The inherited plane accessors plane, width, height and rowStride do not bound p in any build, while the element accessors of this class always address plane 0. The constructor’s single-plane assert validates only the wrapped images, never an accessor argument, and is compiled out when NDEBUG is defined, so a release build silently addresses a multi-plane image as its plane 0.

Template Parameters:

T – Type (it can be const) of each element inside this wrapper.