How to read egl pixel data from a plain cuda kernel?

I have some cuda experience, but am very new to the tegra platform and the egl stream concept.

I am examining the syncSensor sample project from the jetson_multimedia_api package.

jetson_multimedia_api/tree/master/argus/samples/syncSensor

I can read pixel data if I use the cuSurfObjectCreate() boilerplate for the frames and do pixel lookups using surf2Dread() inside my kernel.

But I feel the surfaceobjects are cumbersome and they prevent me from using kernels I have written earlier without rewrite.

I want to run a regular kernel on the two images, so I am trying to pass the frames pPitch pointers directly as unsigned char*.

But I cant seem to get this to work. My kernel crashes immediately.

Can anyone elaborate on why this is the case? Do I need to map the egl frames pointer some way so it is accessible from a regular cuda core?

Kind regards

Jesper

1 Like

Hi,
Please refer to this sample:

/usr/src/jetson_multimedia_api/samples/09_camera_jpeg_capture

You can have frame data in NvBuffer by calling:

iNativeBuffer->createNvBuffer();

or

iNativeBuffer->copyToNvBuffer();

And refer to the function calls for CUDA processing:

static bool
cuda_postprocess(context_t *ctx, int fd)
{
    if (ctx->enable_cuda)
    {
        /* Create EGLImage from dmabuf fd */
        ctx->egl_image = NvEGLImageFromFd(ctx->egl_display, fd);
        if (ctx->egl_image == NULL)
            ERROR_RETURN("Failed to map dmabuf fd (0x%X) to EGLImage",
                    ctx->render_dmabuf_fd);

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

        /* Destroy EGLImage */
        NvDestroyEGLImage(ctx->egl_display, ctx->egl_image);
        ctx->egl_image = NULL;
    }

    return true;
}
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.