Hi,
I’m seeing in the Xavier SoC technical reference manual section “7.3.1.3.9 Blender”, that the VIC has some blend functionalities. I would like to use the “Per-Pixel Non-Premultiplied Alpha Blend output = srcsrc_alpha + dst(1-src_alpha)”.
Does any of the functions in the nvbuf_utils.h library provide this function or any of the other blend modes?
I’ve tried using NvBufferComposite, with composite_flag = NVBUFFER_COMPOSITE | NVBUFFER_BLEND, source and destination dmabuf format = NvBufferColorFormat_ARGB32.
However I get an error saying:
pixel_format must be RGBA for blending operation
nvbuffer_composite Failed
I’ve attached my test code. See function start_vic_composite_mirror_blend(…) camera_v4l2_cuda.cpp (60.4 KB) camera_v4l2_cuda.h (3.7 KB)
How can I use NvBufferComposite to perform Per-Pixel Non-Premultiplied Alpha Blend?
Hi,
In calling NvBufferComposite(), the source buffers are the captured buffers:
for (size_t j = 0; j < V4L2_CAMERAS_NUM; j++)
{
/* Dequeue a camera buff */
memset(&v4l2_buf[j], 0, sizeof(v4l2_buf[j]));
v4l2_buf[j].type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (ctx->capture_dmabuf)
v4l2_buf[j].memory = V4L2_MEMORY_DMABUF;
else
v4l2_buf[j].memory = V4L2_MEMORY_MMAP;
if (ioctl(ctx->cam_fd[j], VIDIOC_DQBUF, &v4l2_buf[j]) < 0)
ERROR_RETURN("Failed to dequeue camera buff: %s (%d)",
strerror(errno), errno);
src_dmabuf_fds[j] = ctx->g_buff[j][v4l2_buf[j].index].dmabuff_fd;
}
for (size_t j = V4L2_CAMERAS_NUM; j < V4L2_CAMERAS_REAL_SIM_NUM; j++)
{
// These buffers are not filled by any real cameras. Just take first buffer e.g. index = 0.
const int index = 0;
src_dmabuf_fds[j] = ctx->g_buff[j][index].dmabuff_fd;
}
The camera sources should be YUV422 such as YUYV or UYVY. Please create NvBuffers in RGBA and convert captured buffers to the NvBuffers through NvBufferTransform(), and set to src_dmabuf_fds in calling NvBufferComposite().
Yes, the captured buffers are in VYUV. They are transformed to the render buffer in NvBufferColorFormat_ARGB32 format. That part works. But the part failing is when I’m trying to blend a “gui buffer” in NvBufferColorFormat_ARGB32 into the render buffer:
Main loop:
if (-1 == NvBufferComposite(&ctx->gui_overlay_dmabuf_fd, ctx->render_dmabuf_fd, &composite_params))
ERROR_RETURN(“Failed to blend ui image into render buffer.”);