Failing to add CUDA processing in libargus sample 09_camera_jpeg_capture

Hi,
I’m trying to add CUDA processing into the multimedia api sample 09_camera_jpeg_capture by added the “handle egl image” part from 12_camera_v4l2_cuda like seen below.
It compiles and link fine.

Running the sample gives no errors, however I cannot see any black rectangle being drawn by cuda in either the rendered display or the saved jpg files.

Am I making any obvious mistakes here?

The gstreamer pipeline with nvivafilter and customer-lib-name=“libnvsample_cudaprocess.so”, works fine.


if (m_dmabuf == -1)
{
m_dmabuf = iNativeBuffer->createNvBuffer(iEglOutputStream->getResolution(),
NvBufferColorFormat_YUV420,
NvBufferLayout_BlockLinear);
if (m_dmabuf == -1)
CONSUMER_PRINT(“\tFailed to create NvBuffer\n”);
}
else if (iNativeBuffer->copyToNvBuffer(m_dmabuf) != STATUS_OK)
{
ORIGINATE_ERROR(“Failed to copy frame to NvBuffer.”);
}

    // Try CUDA processing
    /* Create EGLImage from dmabuf fd */
    EGLDisplay egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    int fd = m_dmabuf;
    EGLImageKHR egl_image = NvEGLImageFromFd(egl_display, fd);
    if (egl_image == NULL)
        CONSUMER_PRINT("Failed to map dmabuf fd (0x%X) to EGLImage", fd);

    /* Pass this buffer hooked on this egl_image to CUDA for
       CUDA processing - draw a rectangle on the frame */
    HandleEGLImage(&egl_image);

    /* Destroy EGLImage */
    NvDestroyEGLImage(egl_display, egl_image);
    egl_image = NULL;
    // Try CUDA processing - end


    /* Process frame. */
    processV4L2Fd(m_dmabuf, iFrame->getNumber());
}

Output from program:
[INFO] (NvEglRenderer.cpp:110) Setting Screen width 640 height 480
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected…
CONSUMER: Waiting until producer is connected…
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3264 H=2464
PRODUCER: [1] W=3264 H=1848
PRODUCER: [2] W=1920 H=1080
PRODUCER: [3] W=1280 H=720
PRODUCER: [4] W=1280 H=720
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
CONSUMER: Done.
CONSUMER: Done.
PRODUCER: Done – exiting.

Hi,
Please create the buffer in NvBufferLayout_Pitch and try again.