CLOSED. cudaArray from NV::IImageNativeBuffer without copy?

Hi Nvidia,

It is possible to use NV::IImageNativeBuffer from camera frame as cudaArray?

NNow i am using this:

UniqueObj< Frame > frameLeft{ iFrameConsumerLeft->acquireFrame() };
IFrame * iFrameLeft{ interface_cast< IFrame >( frameLeft ) }; 

NV::IImageNativeBuffer * iNativeBufferLeft{ interface_cast< NV::IImageNativeBuffer >( iFrameLeft->getImage() ) };
int fdLeft = iNativeBufferLeft->createNvBuffer( STREAM_SIZE, NvBufferColorFormat_YUV420, NvBufferLayout_Pitch );

EGLImageKHR egl_imageLeft{ NvEGLImageFromFd( egl_display, fdLeft ) };

CUgraphicsResource pResourceLeft;

cuGraphicsEGLRegisterImage( & pResourceLeft, * egl_imageLeft, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE );

CUeglFrame eglFrameLeft;

cuGraphicsResourceGetMappedEglFrame( & eglFrameLeft, pResourceLeft, 0, 0 );

[b]cudaArray * ca0, * ca1, * ca2;
cudaChannelFormatDesc channelDesc{ cudaCreateChannelDesc( 8, 0, 0, 0, cudaChannelFormatKindUnsigned ) };

cudaMallocArray( & ca0, & channelDesc, w, h );
cudaMallocArray( & ca1, & channelDesc, w / 2, h / 2 );
cudaMallocArray( & ca2, & channelDesc, w / 2, h / 2 );

cudaMemcpy2DToArray( ca0, 0, 0, ( eglFrameLeft.frame.pArray[ 0 ] ), w, w, h, cudaMemcpyDefault );
cudaMemcpy2DToArray( ca1, 0, 0, ( eglFrameLeft.frame.pArray[ 1 ] ), w / 2, w / 2, h / 2, cudaMemcpyDefault );
cudaMemcpy2DToArray( ca2, 0, 0, ( eglFrameLeft.frame.pArray[ 2 ] ), w / 2, w / 2, h / 2, cudaMemcpyDefault );[/b]

… using cudaArrays ca0, ca1, ca2 …

Best regards, Viktor.

I did it:

UniqueObj< Frame > frameLeft{ iFrameConsumerLeft->acquireFrame() };
IFrame * iFrameLeft{ interface_cast< IFrame >( frameLeft ) }; 

NV::IImageNativeBuffer * iNativeBufferLeft{ interface_cast< NV::IImageNativeBuffer >( iFrameLeft->getImage() ) };
int fdLeft = iNativeBufferLeft->createNvBuffer( STREAM_SIZE, NvBufferColorFormat_YUV420, <b>NvBufferLayout_BlockLinear</b> );

EGLImageKHR egl_imageLeft{ NvEGLImageFromFd( egl_display, fdLeft ) };

CUgraphicsResource pResourceLeft;

cuGraphicsEGLRegisterImage( & pResourceLeft, * egl_imageLeft, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE );

CUeglFrame eglFrameLeft;

cuGraphicsResourceGetMappedEglFrame( & eglFrameLeft, pResourceLeft, 0, 0 );

Now i can use eglFrameLeft as cudaArray:

cudaMemcpy2DFromArray( d, dpitch, <b>( cudaArray * ) eglFrameLeft.frame.pArray[ 0 ]</b>, rectx, recty, rectwidth, rectheight, d2d );

Closed.