Jetson_multimedia_api/samples/12_v4l2_camera_cuda displays garbled output on the monitor

Hi, Dane
sample12 use egl related api to get cuda pointer.
is it possible to use NvBufSurfaceMapCudaBuffer to get cuda pointer?

Hi,
NvBufSurfaceMapCudaBuffer() does same function calls. May to EGLImage first and then get CUDA pointer.

now NvBufSurfaceMapEglImage could get the cuda pointer, but if use NvBufSurfaceMapEglImage(), the demo only can execute at host side, but our demo execute with ssh at the remote machine, it will return error if i call NvBufSurfaceMapEglImage.
vbufsurface: Failed to create EGLImage.
ERROR: cuda_mapping(): (line:716) Failed to register the Egl
ERROR: start_capture(): (line:847) Failed to do the cuda mapping
ERROR: main(): (line:928) Failed to start capturing

Hi,
We would suggest do development on AGX Thor. Need to map NvBufSurface to EglImage and then get CUDA pointer.

Hi, Dane
but how to fix the create EGLImage fail issue if we need to execute the demo at the remote machine that don’t have display device?
below is the error info.
nvbufsurface: Failed to create EGLImage.
ERROR: cuda_mapping(): (line:716) Failed to register the Egl
ERROR: start_capture(): (line:847) Failed to do the cuda mapping
ERROR: main(): (line:928) Failed to start capturing

Hi, Dane
i try to init the display as below shows, now the demo can execute at ssh cmdline that have no display device.

static bool display_initialize(context_t *ctx)
{
EGLint major, minor;
EGLint numConfigs;
EGLConfig config;

// 1. get default display
ctx->egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (ctx->egl_display == EGL_NO_DISPLAY) {
    fprintf(stderr, "Failed to get EGL display\n");
    return false;
}

// 2. init display
if (!eglInitialize(ctx->egl_display, &major, &minor)) {
    fprintf(stderr, "Failed to initialize EGL\n");
    return false;
}

// 3.  config
EGLint attribs[] = {
    EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
    EGL_RED_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_BLUE_SIZE, 8,
    EGL_ALPHA_SIZE, 8,
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
    EGL_NONE
};

if (!eglChooseConfig(ctx->egl_display, attribs, &config, 1, &numConfigs) || numConfigs == 0) {
    fprintf(stderr, "Failed to choose EGL config\n");
    return false;
}

// 4. create Pbuffer Surface
EGLint pbufferAttribs[] = {EGL_WIDTH, 16, EGL_HEIGHT, 16, EGL_NONE}; 
ctx->eglSurface = eglCreatePbufferSurface(ctx->egl_display, config, pbufferAttribs);
if (ctx->eglSurface == EGL_NO_SURFACE) {
    fprintf(stderr, "Failed to create Pbuffer surface\n");
    return false;
}

// 5. create EGLContext
EGLint ctxAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
ctx->egl_context = eglCreateContext(ctx->egl_display, config, EGL_NO_CONTEXT, ctxAttribs);
if (ctx->egl_context == EGL_NO_CONTEXT) {
    fprintf(stderr, "Failed to create EGL context\n");
    return false;
}

// 6. MakeCurrent
if (!eglMakeCurrent(ctx->egl_display, ctx->eglSurface, ctx->eglSurface, ctx->egl_context)) {
    fprintf(stderr, "Failed to make EGL context current\n");
    return false;
}

printf("EGL Pbuffer initialized successfully\n");
return true;

}

1 Like

Hi, Dane
now the zero-copy solution through egl works within the same process, but it doesn’t work across processes.
our logic is camera server process allocate a nvbuffer and send the fd to client process, the client process obtain the fd, and do NvBufSurfaceFromFd and NvBufSurfaceMapEglImage operation, but it will return error when call NvBufSurfaceFromFd function. seems NvBufSurfaceFromFd only work in-process.
below is the error log.
nvbuf_utils: dmabuf_fd 8 mapped entry NOT found
is there any solution to fulfil zero-copy function across processes?

Hi,
For clearness, please make a new topic and we can discuss about sharing NvBufSurface between processes in the new topic thread.

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