Add dsexample>cvmat to the buffer (input of the sgie)


I want to modify each bbox before the sgie. I am using gstdexample.cpp to concatenate the bbox detected by the pgie and my target in order to make person recognition in the sgie.

I am able to make the concatenation with :

in_mat =
cv::Mat (dsexample->processing_height, dsexample->processing_width,
CV_8UC4, dsexample->inter_buf->surfaceList[0].mappedAddr.addr[0],

out_mat = cv::Mat (cv::Size(dest_width, dest_height), CV_8UC3);
cv::cvtColor (in_mat, out_mat, CV_RGBA2BGR);
target = cv::imread(“target.jpg”);
cv::hconcat(out_mat, target, dual_mat);

cv::cvtColor (dual_mat, *dsexample->cvmat, cv::COLOR_RGBA2BGR);

But I don’t know how to add dual_mat to the buffer and give it as input to the sgie.

How can I do that?

Best regards


You will need to add the updated bounding box into metadata.

For example:

// Process to get the output
output =
    DsExampleProcess (dsexample->dsexamplelib_ctx,
// Attach the metadata for the full frame
attach_metadata_full_frame (dsexample, frame_meta, scale_ratio, output, i);
free (output);

The output will be added into metadata and passed into sgie.
So you can try to convert the dual_mat into DsExampleOutput, and attach to the metadata also.


Thanks, one question. For adding bounding box into metadata, which function should I used? attach_metadata_full_frame() or attach_metadata_object()? BEcause in your example you use attach_metadata_full_frame().

Best regards


There are two mechanism in the dsexample: full frame or crop bbox.
Please use the corresponding attach function for each use case.

if (dsexample->process_full_frame) {
    attach_metadata_full_frame (dsexample, frame_meta, scale_ratio, output, i);
} else {
    attach_metadata_object (dsexample, obj_meta, output);

It is controlled by the config file directly:



Thanks, ti works. But I have one more problem.

How can I normalize the data in order to feed the sgie? Beacuse, initially I though that this step was automatically done by the pipeline, and later I realize that it is not done. I try the following code:

img2.convertTo(*dsexample->cvmat, CV_32F, 1.0 / 255, 0);

But it does not work.