I am doing as follows.
NvBufSurface* roi_surface;
NvBufSurface* color_surface;
NvBufSurfaceCreateParams create_params;
create_params.gpuId = dsexample->gpu_id;
create_params.size = 0;
create_params.colorFormat = NVBUF_COLOR_FORMAT_RGBA;
create_params.layout = NVBUF_LAYOUT_PITCH;
create_params.memType = NVBUF_MEM_DEFAULT;
create_params.memType = NVBUF_MEM_CUDA_UNIFIED;
create_params.width = 100;
create_params.height = 200;
cv::Mat roi = in_mat(cv::Rect(x1, y1, x2-x1, y2-y1 ));
cv::Mat color(roi.size(), CV_8UC4, cv::Scalar( 0, 0, 255 ));
double alpha = 0.3;
if (NvBufSurfaceCreate (&roi_surface, 1, &create_params) != 0) {
printf ("Error: in Create\n");
}
NvBufSurfaceMemSet (roi_surface, 0, 0, 0);
if (NvBufSurfaceMap (roi_surface, 0, 0, NVBUF_MAP_READ_WRITE) != 0){
printf("Err in Map\n");
}
if (NvBufSurfaceSyncForCpu (roi_surface, 0, 0) !=0) {
printf("Err in Synccpu");
}
memcpy(roi_surface->surfaceList[0].mappedAddr.addr[0], roi.ptr(), create_params.width * create_params.height * 4);
if (NvBufSurfaceCreate (&color_surface, 1, &create_params) != 0) {
printf ("Error: in Create\n");
}
NvBufSurfaceMemSet (color_surface, 0, 0, 0);
if (NvBufSurfaceMap (color_surface, 0, 0, NVBUF_MAP_READ_WRITE) != 0){
printf("Err in Map\n");
}
if (NvBufSurfaceSyncForCpu (color_surface, 0, 0) !=0) {
printf("Err in Synccpu");
}
memcpy(color_surface->surfaceList[0].mappedAddr.addr[0], color.ptr(), create_params.width * create_params.height * 4);
_NvBufSurfTransformCompositeBlendParams *params;
params->composite_blend_flag=1;
params->input_buf_count=1;
params->src_rect->top=0; params->src_rect->left=0; params->src_rect->width=0; params->src_rect->height=0;
NvBufSurfTransformCompositeBlend(roi_surface->surfaceList[0].mappedAddr.addr[0],
color_surface->surfaceList[0].mappedAddr.addr[0], alpha,
roi_surface->surfaceList[0].mappedAddr.addr[0], ¶ms);
When compiled, I have errors as
gstdsexample.cpp:1017:32: error: ‘struct _NvBufSurfTransformCompositeBlendParams’ has no member named ‘src_rect’
params->src_rect->top=0; params->src_rect->left=0; params->src_rect->width=0; params->src_rect->height=0;
^~~~~~~~
gstdsexample.cpp:1017:57: error: ‘struct _NvBufSurfTransformCompositeBlendParams’ has no member named ‘src_rect’
params->src_rect->top=0; params->src_rect->left=0; params->src_rect->width=0; params->src_rect->height=0;
^~~~~~~~
gstdsexample.cpp:1017:83: error: ‘struct _NvBufSurfTransformCompositeBlendParams’ has no member named ‘src_rect’
params->src_rect->top=0; params->src_rect->left=0; params->src_rect->width=0; params->src_rect->height=0;
^~~~~~~~
gstdsexample.cpp:1017:110: error: ‘struct _NvBufSurfTransformCompositeBlendParams’ has no member named ‘src_rect’
top=0; params->src_rect->left=0; params->src_rect->width=0; params->src_rect->height=0;
^~~~~~~~
gstdsexample.cpp:1018:102: error: invalid conversion from ‘void*’ to ‘NvBufSurface*’ [-fpermissive]
ransformCompositeBlend(roi_surface->surfaceList[0].mappedAddr.addr[0], color_surface->surfaceList[0].mappedAddr.addr[0], alpha,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
gstdsexample.cpp:1018:152: error: invalid conversion from ‘void*’ to ‘NvBufSurface*’ [-fpermissive]
].mappedAddr.addr[0], color_surface->surfaceList[0].mappedAddr.addr[0], alpha,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
gstdsexample.cpp:1019:112: error: cannot convert ‘double’ to ‘NvBufSurface*’ for argument ‘3’ to ‘NvBufSurfTransform_Error NvBufSurfTransformCompositeBlend(NvBufSurface*, NvBufSurface*, NvBufSurface*, NvBufSurface*, NvBufSurfTransformCompositeBlendParams*)’
roi_surface->surfaceList[0].mappedAddr.addr[0], ¶ms);
^
Makefile:74: recipe for target 'gstdsexample.o' failed
Why no member named ‘src_rect’?
How to set parameters for NvBufSurfTransformCompositeBlend?