Hello.
I’m building a deepstream app and I want to customize the input frame. More specifically I want to insert an image right at the bottom of the input frame of the stream. I tried to do it in place with blur-objects
set to TRUE and it worked but that’s not exactly what I want since it hides a large chunk of the stream:
This is the code:
/**
* Called when element recieves an input buffer from upstream element.
*/
static GstFlowReturn
gst_dsexample_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
{
...
/* Cache the mapped data for CPU access */
if(dsexample->inter_buf->memType == NVBUF_MEM_SURFACE_ARRAY)
NvBufSurfaceSyncForCpu (surface, frame_meta->batch_id, 0);
in_mat =
cv::Mat (surface->surfaceList[frame_meta->batch_id].planeParams.height[0],
surface->surfaceList[frame_meta->batch_id].planeParams.width[0], CV_8UC4,
surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0],
surface->surfaceList[frame_meta->batch_id].planeParams.pitch[0]);
}
// My code
cv::Mat smallImagex = cv::imread("/home/nano/test.png", cv::IMREAD_UNCHANGED);
cv::Mat smallImage;
cv::cvtColor (smallImagex, smallImagex, cv::COLOR_BGR2RGBA);
cv::resize(smallImagex, smallImage, cv::Size(dsexample->video_info.width, 200));
cv::Rect destRoi = cv::Rect(0, dsexample->video_info.height-200, dsexample->video_info.width, 200);
cv::resize(in_mat, in_mat, cv::Size(in_mat.cols, in_mat.rows+200));
try {
smallImage.copyTo(in_mat(destRoi));
}
catch (...){
std::cout<<"Exception \n";
}
...
}
But that hides a significant chunk of the stream, I want to do something like this:
Where I insert my custom image underneath the original frame. Of course this means the the dimension of the stream will change, I tried applying cv::resize
on the in_mat
:
/**
* Called when element recieves an input buffer from upstream element.
*/
static GstFlowReturn
gst_dsexample_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
{
...
/* Cache the mapped data for CPU access */
if(dsexample->inter_buf->memType == NVBUF_MEM_SURFACE_ARRAY)
NvBufSurfaceSyncForCpu (surface, frame_meta->batch_id, 0);
in_mat =
cv::Mat (surface->surfaceList[frame_meta->batch_id].planeParams.height[0],
surface->surfaceList[frame_meta->batch_id].planeParams.width[0], CV_8UC4,
surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0],
surface->surfaceList[frame_meta->batch_id].planeParams.pitch[0]);
}
// My code
cv::Mat smallImagex = cv::imread("/home/nano/test.png", cv::IMREAD_UNCHANGED);
cv::Mat smallImage;
cv::cvtColor (smallImagex, smallImagex, cv::COLOR_BGR2RGBA);
cv::resize(smallImagex, smallImage, cv::Size(dsexample->video_info.width, 200));
cv::Rect destRoi = cv::Rect(0, dsexample->video_info.height-200, dsexample->video_info.width, 200);
cv::resize(in_mat, in_mat, cv::Size(in_mat.cols, in_mat.rows+200));
try {
smallImage.copyTo(in_mat(destRoi));
}
catch (...){
std::cout<<"Exception \n";
}
...
}
The resize didn’t work, and my custom image didn’t get added, and the frame is in its original state as if I made no changes on it. I seriously have no idea how to proceed, I would really appreciate your help!
• Hardware Platform (Jetson / GPU)
• DeepStream 6.0
• JetPack 4.6
• TensorRT 8
• Issue Type: question