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);
}
}
}