How to overlay Chinese character string on video picture(tegra_multimedia_api)

Base on example 12_camera_v4l2_cuda,I wonder to overlay Chinese character string instead of drawing a black box in the upper left corner,I changes code as below:

1、 In file camera_v4l2_cuda.cpp(line 556 start):

change function

static bool conv_capture_dqbuf_thread_callback(struct v4l2_buffer *v4l2_buf,
NvBuffer * buffer, NvBuffer * shared_buffer,
void *arg)
{
context_t *ctx = (context_t *) arg;

if (ctx->enable_cuda)
{
    // Create EGLImage from dmabuf fd
    ctx->egl_image = NvEGLImageFromFd(ctx->egl_display, buffer->planes[0].fd);
    if (ctx->egl_image == NULL)
        ERROR_RETURN("Failed to map dmabuf fd (0x%X) to EGLImage",
                buffer->planes[0].fd);

    // Running algo process with EGLImage via GPU multi cores
    HandleEGLImage(&ctx->egl_image);

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

// Render the frame into display
if (v4l2_buf->m.planes[0].bytesused)
    ctx->renderer->render(buffer->planes[0].fd);

if (ctx->conv->capture_plane.qBuffer(*v4l2_buf, buffer) < 0)
{
    abort(ctx);
    ERROR_RETURN("Failed to queue buffer on VIC capture plane");
}

return true;

}

to

static bool conv_capture_dqbuf_thread_callback(struct v4l2_buffer *v4l2_buf,
NvBuffer * buffer, NvBuffer * shared_buffer,
void *arg)
{
context_t *ctx = (context_t *) arg;

if (ctx->enable_cuda)
{
    ctx->renderer->setOverlayText("显示中文", 50, 50);
}

// Render the frame into display
if (v4l2_buf->m.planes[0].bytesused)
    ctx->renderer->render(buffer->planes[0].fd);

if (ctx->conv->capture_plane.qBuffer(*v4l2_buf, buffer) < 0)
{
    abort(ctx);
    ERROR_RETURN("Failed to queue buffer on VIC capture plane");
}

return true;

}

when using ctx->renderer->setOverlayText(“abcde”, 50, 50); the result is what I want,on video string “abcde” overlay displayed on video.

2、 in file NvEglRenderer.cpp

in function NvEglRenderer::NvEglRenderer(const char *name, uint32_t width, uint32_t height,
uint32_t x_offset, uint32_t y_offset)
:NvElement(name, valid_fields)
change

fontinfo = XLoadQueryFont(x_display, “9x15bold”);

to

fontinfo = XLoadQueryFont(x_display, “hanzigb16fs”);

hanzigb16fs means “-isas-fangsong ti-medium-r-normal–16-160-72-72-c-160-gb2312.1980-0”
(etc——>x11——>fonts——>misc——>xfonts-base.alias)

there is nothing overlay displayed on video.

what else should I to do?
thanks!

Hi Fengbaoying,
I am not sure our platform can draw Chinese with X11.

I suggest you draw Chinese character to a surface(buffer), then Blit it to your video with VIC.

Thanks
wayne zhu