the size of saved image is wrong in Dsexample

I try to save the detect image in Dsexample base the detect result. but found the size of saved image is wrong. it is different with the printed width and height.
I was try to change "dsexample->processing_height, dsexample->processing_width " as src_width and src_height. it was wrong yet. do you know why? how can I get correct detect bounding box and image. thanks.

the following is the code in gstdsexample.cpp: the * part is the change part.

in function get_converted_mat

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

cv::cvtColor (in_mat, *dsexample->cvmat, CV_RGBA2BGR);
/**************************saved the mat to jpg/
cv::imwrite(“test.jpg”,*dsexample->cvmat);

in function gst_dsexample_transform_ip

#to check per frame and per object
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next)
{
frame_meta = (NvDsFrameMeta *) (l_frame->data);
for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
l_obj = l_obj->next)
{
obj_meta = (NvDsObjectMeta *) (l_obj->data);

    /* Should not process on objects smaller than MIN_INPUT_OBJECT_WIDTH x MIN_INPUT_OBJECT_HEIGHT
     * since it will cause hardware scaling issues. */
    if (obj_meta->rect_params.width < MIN_INPUT_OBJECT_WIDTH ||
        obj_meta->rect_params.height < MIN_INPUT_OBJECT_HEIGHT)
      continue;

    // Crop and scale the object
    if (get_converted_mat (dsexample,
          surface, frame_meta->batch_id, &obj_meta->rect_params,
          scale_ratio, dsexample->video_info.width,
          dsexample->video_info.height) != GST_FLOW_OK) {
      // Error in conversion, skip processing on object. */
      continue;
    }
   
    // Process the object crop to obtain label
    output = DsExampleProcess (dsexample->dsexamplelib_ctx,
        dsexample->cvmat->data);
    /*****************************print the detect object width and height******************/
    std::cout<<obj_meta->rect_params.width<<" "<<obj_meta->rect_params.height<<std::endl;


    // Attach labels for the object
    attach_metadata_object (dsexample, obj_meta, output);

    free (output);
  }
}

}

Hi,
Please configure processing-width and processing-height same as output resolution of nvstreammux.

[ds-example]
enable=1
processing-width=640
processing-height=480
full-frame=0
unique-id=15
gpu-id=0

Can we add new parameters inside ds-example block ? As an example

[ds-example]
enable=1
processing-width=1280
processing-height=720
full-frame=1
unique-id=15
x-coordinate-top=642
y-coordinate-top=10
x-coordinate-bottom=618
y-coordinate-bottom=720

Hi,
You may use NvBufSurface APIs to customize dsexample for your usecase. There are samples. Please refer to 2, 5 in FAQ

Hi malith,

you can add parameters to the example block and you have to install them, by calling the function

g_object_class_install_property

The properties must also be added to the functions

gst_dsexample_set_property

and

gst_dsexample_get_property

You can add them just as the parameters which are used by dsexample

I have already done that. But the issue remains. I have tried the steps mentioned by nvidia dev staff in my original thread, but now I have an issue doing that. If you have any other solution please mention it on https://devtalk.nvidia.com/default/topic/1064850/deepstream-sdk/how-to-add-new-parameters-to-deepstream_app_config_yolov2_tiny-txt-file-/