CUDA Kernel functions don't work with Multimedia API

Hi,

I am trying to create a CUDA application that applies an processing algorithm to each video frame decoded from a video file (H264).

I downloaded the multimedia API from the Jetson Download Center (both releases 32.2.1 and 28.3.1) and compiled the sample 02 (video decoder + cuda).

The sample 02 is supposed to draw a square (32 x 32) on top of the video decoded, however, I can see no square at all. Video displays fine.

I tried in the the Nano and in the Xavier. Both behave the same way.

I tried to change the square color/size but never was able to see any square. and changed the kernel call in different ways to try to display something, always unsuccessful

However, a call to a CudaMemset applies the color to the screen fine. The problem appears to be only when kernel calls happen

from tegra_multimedia_api/samples/common/algorithm/cuda/NvCudaProc.cpp

/**
  * Performs CUDA Operations on egl image.
  *
  * @param image : EGL image
  */
static void
Handle_EGLImage(EGLImageKHR image)
{
    CUresult status;
    CUeglFrame eglFrame;
    CUgraphicsResource pResource = NULL;

    cudaFree(0);
    status = cuGraphicsEGLRegisterImage(&pResource, image,
                CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE);
    if (status != CUDA_SUCCESS)
    {
        printf("cuGraphicsEGLRegisterImage failed: %d, cuda process stop\n",
                        status);
        return;
    }

    status = cuGraphicsResourceGetMappedEglFrame(&eglFrame, pResource, 0, 0);
    if (status != CUDA_SUCCESS)
    {
        printf("cuGraphicsSubResourceGetMappedArray failed\n");
    }

    status = cuCtxSynchronize();
    if (status != CUDA_SUCCESS)
    {
        printf("cuCtxSynchronize failed\n");
    }

    if (eglFrame.frameType == CU_EGL_FRAME_TYPE_PITCH)
    {
        //Rect label in plan Y, you can replace this with any cuda algorithms.
        //addLabels((CUdeviceptr) eglFrame.frame.pPitch[0], eglFrame.pitch); //does not display any square or anything
       <b> cudaMemset((void *)eglFrame.frame.pPitch[0], 120, eglFrame.pitch)</b> //displays a gray line
    }

    status = cuCtxSynchronize();
    if (status != CUDA_SUCCESS)
    {
        printf("cuCtxSynchronize failed after memcpy\n");
    }

    status = cuGraphicsUnregisterResource(pResource);
    if (status != CUDA_SUCCESS)
    {
        printf("cuGraphicsEGLUnRegisterResource failed: %d\n", status);
    }
}

So, did anybody ever get kernel calls to change a buffer using this Multimedia API?

Hi,
Please install whole package through sdkmanager and then run

$ export DISPLAY=:1
$ /usr/src/tegra_multimedia_api/samples/02_video_dec_cuda/video_dec_cuda /usr/src/tegra_multimedia_api/data/Video/sample_outdoor_car_1080p_10fps.h264 H264

Hi DaneLLL,

I tried reinstalling everything again and running the commands above, and the behaviour is the same. I see no squares at all.

I used JetPack 4.2.2 and the release 32.2 (flashed new OS image as well).

The video runs but I see no squares. I tried also with a Jetson Nano and no squares in the Nano as well.

I attached a screenshot of the video running.

Hi,
Please try

$ gst-launch-1.0 videotestsrc num-buffers=400 ! nvvidconv ! nvv4l2h264enc ! h264parse ! video/x-h264,stream-format=byte-stream ! filesink location=a.h264
$ /usr/src/tegra_multimedia_api/samples/02_video_dec_cuda/video_dec_cuda a.h264 H264

sample_outdoor_car_1080p_10fps.h264 is pretty dark at top-left corner and it is not obvious.

Hi DaneLLL, It’s clear now, it was my mistake. It works fine

The square is drawn exactly at the dark spot.

Thanks!