How to composite several picture by NvBufferTransform

UI layer has defined the interface similarly composite(src, dst), the UI layer will use it like that composite(fd1, fd),composite(fd2, fd)…composite(fdn, fd), fd1,2,3,4,5…n are the pictures. fd is the assemble of pictures.
I want to know if I can composite the picture by using NvBufferTransform. Here is my code. But I found that the fdn will cover the fd(n-1),though all the pictures positions are correct.

NvBufferRect src_rect, dst_rect;
dst_rect.top = vrDst.Y;
dst_rect.left = vrDst.X;
dst_rect.width = vrDst.Width;
dst_rect.height = vrDst.Height;
src_rect.top = vrSrc.Y;
src_rect.left = vrSrc.X;
src_rect.width = vrSrc.Width;
src_rect.height = vrSrc.Height;
NvBufferTransformParams transform_params;
memset(&transform_params, 0, sizeof(transform_params));
transform_params.transform_flag = NVBUFFER_TRANSFORM_FILTER | NVBUFFER_TRANSFORM_CROP_DST;
transform_params.transform_flip = NvBufferTransform_None;
transform_params.transform_filter = NvBufferTransform_Filter_Nearest;
transform_params.src_rect = src_rect;
transform_params.dst_rect = dst_rect;
NvBufferTransform(src_fd, dst_fd, &transform_params);

Hi,
You may try NvBufferComposite(). The function can be used to composite multiple NvBuffer in single function call. There is demo code in 13_multi_camera sample and please take a look.

Hello!
I used NvBufferComposite() but the same phenomenon.

NvBufferRect src_rect, dst_rect;
dst_rect.top = vrDst.Y;
dst_rect.left = vrDst.X;
dst_rect.width = vrDst.Width;
dst_rect.height = vrDst.Height;
src_rect.top = vrSrc.Y;
src_rect.left = vrSrc.X;
src_rect.width = vrSrc.Width;
src_rect.height = vrSrc.Height;

NvBufferCompositeParams m_compositeParam;
memset(&m_compositeParam, 0, sizeof(m_compositeParam));
m_compositeParam.composite_flag = NVBUFFER_COMPOSITE;
m_compositeParam.input_buf_count = 1;
memcpy(&m_compositeParam.dst_comp_rect[0], &dst_rect, sizeof(NvBufferRect));
m_compositeParam.dst_comp_rect_alpha[0] = 1.0f;
memcpy(&m_compositeParam.src_comp_rect[0], &src_rect, sizeof(NvBufferRect));

NvBufferComposite(&src_fd, dst_fd, &m_compositeParam);

Hi,

This can be set to multiple input buffers. Please refer to code in this function:

bool ConsumerThread::threadInitialize()

That means input_buf_count is 2 at least?
Can I use NvTransform to composite the picture? Because NvBufferComposite just has 16 channel. But I have to more than 16 and one picture is so small.

Hi,
The NvBufferTransform() function is designed for scaling/cropping/conversion. The interface is one source buffer and one destination buffer. It is not able to set up multiple buffers. If you need to composite multiple buffers into single video plane, we would suggest call NvBufferComposite()

For optimal performance of NvBufferTransform()/NvBufferComposite(), please do

  1. Run hardware converter at maximum clock:
    Nvvideoconvert issue, nvvideoconvert in DS4 is better than Ds5? - #3 by DaneLLL
  2. Create NvBufferSession for each NvBufferTransfrom()/NvBufferComposite() task

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