Using a CUDA buffer with visionworks

Hi,

I was reviewing the Visionworks documentation and the samples/demos and ran into the following question:

Let us assume I have an array that is allocated using cudaMallocManaged which is an image. How can I pass this into Visionworks for let’s say feature tracking, OR,

let us say I have 2 arrays (ie. 2 frames of a video). How can I pass these into Visionworks to do motion estimation?

Thanks.

Hi,

You can find some information in our document here:
https://developer.nvidia.com/embedded/dlc/visionworks-1-6-documentation-for-l4t-27-1

VisionWorks API
> Tutorials
> NVX CUDA API Tutorial
> Data Object Creation

nvxcu_pitch_linear_image_t createImageU8(uint32_t width, uint32_t height)
{
    void *dev_ptr = NULL;
    size_t pitch = 0;
    cudaMallocPitch(&dev_ptr, &pitch, width * sizeof(uint8_t), height);
    nvxcu_pitch_linear_image_t image;
    image.base.image_type = NVXCU_PITCH_LINEAR_IMAGE;
    image.base.format = NVXCU_DF_IMAGE_U8;
    image.base.width = width;
    image.base.height = height;
    image.planes[0].dev_ptr = dev_ptr;
    image.planes[0].pitch_in_bytes = pitch;
    return image;
}

Thanks.

Thanks for your reply. This talks about creating an image buffer right?

I have already created a buffer using cudaMallocManaged. How do I use this as my image buffer and pass it to nvx? Does this make sense?

Hi,

So you can replace this line to your buffer information:

    cudaMallocPitch(&dev_ptr, &pitch, width * sizeof(uint8_t), height);

Thanks.

1 Like