Xavier NX add new object in dsexample

Please provide complete information as applicable to your setup.

**• Hardware Platform Jetson
**• DeepStream Version 6.0
**• JetPack Version 4.6.1

Hello everyone and professors:
I meet a problem about add a new object in dsexample.

(1) In the GPU computer, I added a new object in dsexample, and use SGIE to classify it. In the GPU computer, It works fine.

(2) I move the same code and configure text into Xavier NX. I can not find the added new object! What is the problem?

My add new object code as below:

static GstFlowReturn
gst_dsexample_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
{
int n_area=0;
int n_rows=0;
int temp_i;
int temp_j;
int fence_point_data[100][4]={0};
int summary_info[10][2]={0};

GstDsExample *dsexample = GST_DSEXAMPLE (btrans);
GstMapInfo in_map_info;
GstFlowReturn flow_ret = GST_FLOW_ERROR;
gdouble scale_ratio = 1.0;
DsExampleOutput *output;

NvBufSurface *surface = NULL;
NvDsBatchMeta *batch_meta = NULL;
NvDsFrameMeta *frame_meta = NULL;
NvDsMetaList * l_frame = NULL;
guint i = 0;

dsexample->frame_num++;
CHECK_CUDA_STATUS (cudaSetDevice (dsexample->gpu_id),
“Unable to set cuda device”);

memset (&in_map_info, 0, sizeof (in_map_info));
if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ))
{
g_print (“Error: Failed to map gst buffer\n”);
goto error;
}

nvds_set_input_system_timestamp (inbuf, GST_ELEMENT_NAME (dsexample));
surface = (NvBufSurface *) in_map_info.data;
GST_DEBUG_OBJECT (dsexample,
“Processing Frame %” G_GUINT64_FORMAT " Surface %p\n",
dsexample->frame_num, surface);

if (CHECK_NVDS_MEMORY_AND_GPUID (dsexample, surface))
goto error;
batch_meta = gst_buffer_get_nvds_batch_meta (inbuf);
if (batch_meta == nullptr)
{
GST_ELEMENT_ERROR (dsexample, STREAM, FAILED,
(“NvDsBatchMeta not found for input buffer.”), (NULL));
return GST_FLOW_ERROR;
}
if (1)
{
NvDsMetaList * l_obj = NULL;
NvDsObjectMeta *obj_meta = NULL;
int camera_type;
for(l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next)
{
frame_meta = (NvDsFrameMeta *) (l_frame->data);
static int area_top = 700;
static int area_left = 700;
int area_width = 1000;
int area_height = 200;
int max_bottom = 0 ;
int limit_bottom = 200;
int min_left = 1920;
int obj_num = 0;

    for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;  l_obj = l_obj->next)
    {
        obj_meta = (NvDsObjectMeta *) (l_obj->data);
        if(obj_meta->class_id == 0)
        {
            if((obj_meta->rect_params.top + obj_meta->rect_params.height) > max_bottom)
            {
               max_bottom = obj_meta->rect_params.top + obj_meta->rect_params.height;
            }
            if(obj_meta->rect_params.left < min_left)
            {
               min_left = obj_meta->rect_params.left ;
            }

            if(obj_meta->rect_params.left < 960)
            { obj_num++; }
        }

    }
    if(obj_num > 3)
    {

// cout<< "max_bottom= “<<max_bottom<< " min_left=”<< min_left<<endl;
if (min_left > (1920 - area_width) )
min_left = (1920 - area_width);

        if (max_bottom > (1080 - limit_bottom))
            max_bottom = (1080 - limit_bottom);

        if(max_bottom < area_height )
            max_bottom = area_height;

        area_top = max_bottom - area_height;
        area_left = min_left;

// cout<<“area_top=” << area_top <<" area_left = "<< area_left <<endl<<endl;
}

    if (my_save_mat(dsexample, surface, frame_meta->batch_id, scale_ratio,
                  area_left, area_top, area_width, area_height) != GST_FLOW_OK)
    {
                /* Error in conversion, skip processing on object. */
                continue;
    }
  NvDsObjectMeta *my_obj_meta = nvds_acquire_obj_meta_from_pool (batch_meta);
  my_obj_meta->unique_component_id = 1;
  my_obj_meta->confidence = 1;
  my_obj_meta->class_id = 5;
  my_obj_meta->object_id = 100;
  NvOSD_RectParams & set_rect_params = my_obj_meta->rect_params;
  set_rect_params.left = area_left;
  set_rect_params.top = area_top;
  set_rect_params.width = area_width;
  set_rect_params.height = area_height;
  set_rect_params.has_bg_color = 0;
  set_rect_params.border_width = 3;
  my_obj_meta->detector_bbox_info.org_bbox_coords.left = set_rect_params.left;
  my_obj_meta->detector_bbox_info.org_bbox_coords.top = set_rect_params.top;
  my_obj_meta->detector_bbox_info.org_bbox_coords.width = set_rect_params.width;
  my_obj_meta->detector_bbox_info.org_bbox_coords.height = set_rect_params.height;
  nvds_add_obj_meta_to_frame (frame_meta, my_obj_meta, NULL);
  cout<<" I am in dsexample "<<endl;
 }// end frame

} //end if(1)

flow_ret = GST_FLOW_OK;

error:

nvds_set_output_system_timestamp (inbuf, GST_ELEMENT_NAME (dsexample));
gst_buffer_unmap (inbuf, &in_map_info);
return flow_ret;
}

the output can finde the print information " I am in dsexample " that means the dsexample works. But I print the detected object in deepstream-app-main.c as below:

static GstPadProbeReturn
sgie_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
{
static guint use_device_mem = 0;
NvDsBatchMeta batch_meta = gst_buffer_get_nvds_batch_meta (GST_BUFFER (info->data));
/
Iterate each frame metadata in batch */
for(NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next)
{
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) l_frame->data;
for(NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL; l_obj = l_obj->next)
{
NvDsObjectMeta *obj_meta = (NvDsObjectMeta *) l_obj->data;
// if(obj_meta->class_id==5)
printf(“class_id = %d, obj_id = %d width = %f height = %f \n”,
obj_meta->class_id,
obj_meta->object_id,
obj_meta->rect_params.width,
obj_meta->rect_params.height
);
}
}
return GST_PAD_PROBE_OK;
}

but I can not get the object whoes classs_id = 5

Please kindly help me . Thank you very much.



the up fig is the result.
We can see, the object can be found in the scream, but can not be found in the print information.

I test another method. Before, I added a new class of object: class_id=5, object_id =100. It can not be sent to SGIE. Now I add a existing class object: class_id=0, object_id=5000, width =1000, height=200. and I set the input-object-min-width=100, input-object-min-height = 100. But It can not be sent to SGIE too.

I double checked the configuration txt and code, I can not find the problem by myself. I guess if there is configuration parameter that I set wrong? Or Jetson can not add new object after PGIE and sent it to SGIE.

This problem makes me in deep trobule. Help. Thank you very much.

please narrow down this issue. add probe to dsexample src, check if object list size is changed, check if new object is added.

Thank you very much. I found the problem, because I add the dsexample behind the SGIE. Acturally, it must add behind PGIE.

Glad to know you fixed it, thanks for the update!

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