Hi @SivaRamaKrishnaNV,
First, a NvMediaImage is created using the code below
// set NvMediaSurfAllocAttr…
NVM_SURF_FMT_DEFINE_ATTR(surfFormatAttrs);
NVM_SURF_FMT_SET_ATTR_RGBA(surfFormatAttrs, RGBA, UINT, 8, PL);
NvMediaSurfaceType surfaceType = NvMediaSurfaceFormatGetType(surfFormatAttrs, NVM_SURF_FMT_ATTR_MAX);
NvMediaImage *img = NvMediaImageCreateNew(device, surfaceType, surfAllocAttrs.data(), surfAllocAttrs.size(), 0);
After this, the img can be used normally, and I can use JPG decoder to fill it with an image. However, its memory layout will be interleaved instead of planar. Also, the data cannot be used as NHWC layout because its surface type is RGBA instead of RGB, which makes channel number = 4 rather than 3 that most neural networks are trained with.
If I try to manually set the memory layout to planar, replace NVM_SURF_FMT_SET_ATTR_RGBA() with its definition (line 287 of nvmedia_surface.h) and set NVM_SURF_ATTR_MEMORY to be planar, then the code becomes:
// set NvMediaSurfAllocAttr…
NVM_SURF_FMT_DEFINE_ATTR(surfFormatAttrs);
surfFormatAttrs[0].type = NVM_SURF_ATTR_SURF_TYPE;
surfFormatAttrs[0].value = NVM_SURF_ATTR_SURF_TYPE_RGBA;
surfFormatAttrs[1].type = NVM_SURF_ATTR_LAYOUT;
surfFormatAttrs[1].value = NVM_SURF_ATTR_LAYOUT_PL;
surfFormatAttrs[2].type = NVM_SURF_ATTR_DATA_TYPE;
surfFormatAttrs[2].value = NVM_SURF_ATTR_DATA_TYPE_UINT;
surfFormatAttrs[3].type = NVM_SURF_ATTR_MEMORY;
surfFormatAttrs[3].value = NVM_SURF_ATTR_MEMORY_PLANAR; // Changed to planar
surfFormatAttrs[4].type = NVM_SURF_ATTR_SUB_SAMPLING_TYPE;
surfFormatAttrs[4].value = 0;
surfFormatAttrs[5].type = NVM_SURF_ATTR_BITS_PER_COMPONENT;
surfFormatAttrs[5].value = NVM_SURF_ATTR_BITS_PER_COMPONENT_8;
surfFormatAttrs[6].type = NVM_SURF_ATTR_COMPONENT_ORDER;
surfFormatAttrs[6].value = NVM_SURF_ATTR_COMPONENT_ORDER_RGBA;
NvMediaSurfaceType surfaceType = NvMediaSurfaceFormatGetType(surfFormatAttrs, NVM_SURF_FMT_ATTR_MAX);
NvMediaImage *img = NvMediaImageCreateNew(device, surfaceType, surfAllocAttrs.data(), surfAllocAttrs.size(), 0);
The I would get the runtime error
[NvMImageParseSurfAllocAttr:367] Surface allocation unsupported for the surface type 99999
[NvMediaImageCreateNew:844] NvMImageParseSurfAllocAttr failed
I would like to avoid using DW APIs as we were told the safety certification of DW comes much later than DRIVE OS. What about NvMedia APIs like NvMediaTensor? I couldn’d find much documentations about that. Would NvMediaTensor be Nvidia’s envisioned interface for bridging NvMediaImage and TensorRT?