Function nvcvTensorWrapImageConstruct

Function Documentation

NVCVStatus nvcvTensorWrapImageConstruct(NVCVImageHandle img, NVCVTensorHandle *handle)

Wraps an existing NVCV image into an NVCV tensor instance constructed in given storage

Tensor layout is inferred from image characteristics.

  • CHW: For multi-planar images, one-channel image or single-planar images whose channels have different bit depths.

  • HWC: For packed (single plane) images with channels with same bit depths

When image is single-planar with channels with different bit depths, it’s considered to have one channel, but with element type (type) with multiple components with the required bit depth each.

The tensor created by this function holds a reference to the image. The image handle can be safely released and the image object will be kept alive at least as long as the tensor that wraps it.

Parameters:
  • img[in] Image to be wrapped

    • Must not be NULL.

    • Must not have subsampled planes

    • All planes must have the same data type.

    • Distance in memory between consecutive planes must be > 0.

    • Row pitch of all planes must be the same.

    • Image must not be destroyed while it’s referenced by a tensor.

    • Image contents must be cuda-accessible

    • Image format must be pitch-linear.

    • All planes must have the same dimensions.

  • handle[out] Where the tensor instance handle will be written to.

    • Must not be NULL.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_SUCCESS – Operation executed successfully.