• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing) • Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
You can add that in the probe function like osd_sink_pad_buffer_probe in the sources\apps\sample_apps\deepstream-test1\deepstream_test1_app.c. Based on the coordinates of the bbox, you can draw width and height onto the bbox. You can refer to the source code above to draw the text.
Actually, we have to make changes in deepstream_test1_app.c ? or we have export code from deepstream_test1_app.c to nvdsparseseg_Yolo.cpp ? Since, all code executed : object passed to deepstream 7.0 , so I have to make changes in files in deepstream 7.0 Right ?
Hi, can you please show clarity in message. Where is NvDsDisplayMeta Structure file located ? is this file located in DeepStream 7.0 ? Should I have to make changes here ?
Let me take our open source deepstream_test1_app.c as an example.
The probe function: osd_sink_pad_buffer_probe
NvDsDisplayMeta : NvDsDisplayMeta *display_meta = NULL;
We recommend that you first take a brief look at DeepStream’s samples and run 1 0r 2 our demos.
It depends on which demo you are using. If you are using deepstream-test1, you have to make changes in the deepstream_test1_app.c. If you are using other demos, you have to make changes in the corresponding demo.
// Callback function for the OSD sink pad buffer probe
static GstPadProbeReturn
osd_sink_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
{
// Check if the probe is for a buffer
if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_BUFFER) {
GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER(info);
if (!buf) {
return GST_PAD_PROBE_OK;
}
// Extract metadata from the buffer
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);
if (!batch_meta) {
return GST_PAD_PROBE_OK;
}
// Iterate through each frame's metadata
for (NvDsMetaList *l_frame = batch_meta->frame_meta_list; l_frame; l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)l_frame->data;
// Iterate through each object in the frame
for (NvDsMetaList *l_obj = frame_meta->obj_meta_list; l_obj; l_obj = l_obj->next) {
NvDsObjectMeta *obj_meta = (NvDsObjectMeta *)l_obj->data;
// Check if `rect_params` has valid values
if (obj_meta->rect_params.left >= 0 && obj_meta->rect_params.top >= 0) {
std::string mask_info_text = "Mask - Width: " + std::to_string(obj_meta->rect_params.width) +
", Height: " + std::to_string(obj_meta->rect_params.height) +
", X: " + std::to_string(obj_meta->rect_params.left) +
", Y: " + std::to_string(obj_meta->rect_params.top);
// Allocate display meta
NvDsDisplayMeta *display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
if (!display_meta) {
std::cerr << "ERROR: Unable to acquire display meta from pool" << std::endl;
continue;
}
// Initialize and set text parameters
NvOSD_TextParams *txt_params = &display_meta->text_params[0];
display_meta->num_labels = 1;
txt_params->display_text = (char *)g_malloc0(MAX_DISPLAY_LEN);
if (!txt_params->display_text) {
std::cerr << "ERROR: Unable to allocate memory for display text" << std::endl;
continue;
}
snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "%s", mask_info_text.c_str());
// Set the offsets where the string should appear
txt_params->x_offset = obj_meta->rect_params.left;
txt_params->y_offset = obj_meta->rect_params.top;
// Font, font-color, and font-size
txt_params->font_params.font_name = g_strdup("Serif");
txt_params->font_params.font_size = 12;
txt_params->font_params.font_color.red = 0.0;
txt_params->font_params.font_color.green = 1.0;
txt_params->font_params.font_color.blue = 0.0;
txt_params->font_params.font_color.alpha = 1.0;
// Text background color
txt_params->set_bg_clr = 1;
txt_params->text_bg_clr.red = 0.0;
txt_params->text_bg_clr.green = 0.0;
txt_params->text_bg_clr.blue = 0.0;
txt_params->text_bg_clr.alpha = 1.0;
// Add display meta to frame
nvds_add_display_meta_to_frame(frame_meta, display_meta);
}
}
}
}
return GST_PAD_PROBE_OK;
You cannot modify the code in the postprocess. Since you are using the DeepStream-Yolo-Seg. It’s executed with our deepstream-app demo. So you need to modify this demo code : sources\apps\sample_apps\deepstream-app. This demo is open source and you can debug that directly.
Idea yet not clear. How about chaining the code in nvdsparseseg_Yolo.cpp and generate .so file using make commond CUDA_VER=11.4 make -C nvdsinfer_custom_impl_Yolo_seg and execute. It must work. Right ? if we modify demo code sources\apps\sample_apps\deepstream-app we have to change which code file deepstream_app_main.c
eepstream_app_config_parser.c
deepstream_app.c deepstream_app_config_parser_yaml.cpp ?
Even after chainging overlay_graphics in /opt/nvidia/deepstream/deepstream-6.3/sources/apps/sample_apps/deepstream-app/ deepstream_app_main.c, it does not display the width, height of segmentation mask over the bounding box
Done in changes : deepstream_app.c it does not display the width, height of segmentation mask over the bounding box
static void
process_meta (AppCtx * appCtx, NvDsBatchMeta * batch_meta)
{
// For single source always display text either with demuxer or with tiler
if (!appCtx->config.tiled_display_config.enable ||
appCtx->config.num_source_sub_bins == 1) {
appCtx->show_bbox_text = 1;
}
Can you improve you suggestion so that can be easily understand everyone. Seem like just moving from here and their. Please explain elaborately your clear idea.
Each of the demo I’ve attached is how to use display_meta to draw something on an image.
I will explain the detailed process again. For the details of the code, please refer to all the demos I attached.
1.Get the NvDsBatchMeta from the gstbuffer.
Text:
NvOSD_TextParams *txt_params = &display_meta->text_params[0];
...define the parameters of NvOSD_TextParams...
Rectangle:
NvOSD_RectParams *rect_params = &display_meta->rect_params[0];
...define the parameters of NvOSD_RectParams...
Drawing line, arrow, circle is basically the same process as above
In the DeepStream-Yolo-Seg their is no .c file . Which code I should execute then ? You said It’s executed with our deepstream-app demo. So you need to modify this demo code : sources\apps\sample_apps\deepstream-app. Then question is which file I should copy ? which file I should make changes ? even consider two file nvdsparseseg_Yolo.cpp and deepstream_app_main.c, : even reflected changes as you mention, error will be continue. please read carefully comment and answer carefully ? Seem question unaddressable. Thank you for your patience.
You modified the code in the right position before, maybe the way it was used was wrong.
It’s C/C++ code. Have you run the make and make install command after modifying the code?
Please follow the detailed steps I attached before to modify the code.