Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) Orin 64G development kit
• DeepStream Version 7.1
• JetPack Version (valid for Jetson only) 6.1
I am trying to save jpg image in deepstream_parallel_inference_app.
Added the following code into osd_sink_pad_buffer_probe.
GstMapInfo in_map_info;
memset (&in_map_info, 0, sizeof (in_map_info));
if (!gst_buffer_map (buf, &in_map_info, GST_MAP_READ)) {
g_print ("Error: Failed to map gst buffer\n");
return GST_PAD_PROBE_OK;
}
surface = (NvBufSurface *) in_map_info.data;
Then the whole application is freezed.
osd_sink_pad_buffer_probe probe is attached to tiled_display_bin as
osd_sink_pad = gst_element_get_static_pad(pipeline->tiled_display_bin.tiler, "sink");
if (!osd_sink_pad)
g_print("Unable to get sink pad\n");
else {
gst_pad_add_probe(osd_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
osd_sink_pad_buffer_probe, NULL, NULL);
LatencyCtx *ctx = (LatencyCtx *)g_malloc0(sizeof(LatencyCtx));
ctx->lock = (GMutex *)g_malloc0(sizeof(GMutex));
ctx->num_sources = config->num_source_sub_bins;
gst_pad_add_probe (osd_sink_pad, GST_PAD_PROBE_TYPE_BUFFER,
latency_measurement_buf_prob, ctx, NULL);
}
I like to have bounding boxes in the saved images. Since tiled_display_bin is last stage in the pipeline after osd has plotted bounding boxes, it is considered the bounding boxes are in the saved images.
That is the reason, jpg is saved in the osd_sink_pad_buffer_probe.
The whole loop is shown below.
static GstPadProbeReturn
osd_sink_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info,
gpointer u_data)
{
GstBuffer *buf = (GstBuffer *)info->data;
guint num_rects = 0;
NvDsObjectMeta *obj_meta = NULL;
NvDsMetaList *l_frame = NULL;
NvBufSurface *surface = NULL;
NvDsMetaList *l_obj = NULL;
NvDsDisplayMeta *display_meta = NULL;
gboolean is_first_object = TRUE;
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);
GstMapInfo in_map_info;
std::vector<int> cams;
zones_display.get_cameras(cams);
memset (&in_map_info, 0, sizeof (in_map_info));
if (!gst_buffer_map (buf, &in_map_info, GST_MAP_READ)) {
g_print ("Error: Failed to map gst buffer\n");
return GST_PAD_PROBE_OK;
}
surface = (NvBufSurface *) in_map_info.data;
int offset = 0;
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next)
{
is_first_object = TRUE;
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);
bool saved=false;
for (l_obj = frame_meta->obj_meta_list; l_obj != NULL; l_obj = l_obj->next)
{
obj_meta = (NvDsObjectMeta *)(l_obj->data);
//cout << "source id " << frame_meta->source_id << " id " << obj_meta->object_id << " class " << obj_meta->class_id << endl;
if(saved==false){
NvDsObjEncUsrArgs frameData = { 0 };
frameData.isFrame = 1;
frameData.saveImg = true;
frameData.attachUsrMeta = false;
frameData.scaleImg = FALSE;
std::string str = "source_"+std::to_string(frame_meta->source_id)+".jpg";
strcpy(frameData.fileNameImg, str.c_str());
frameData.scaledWidth = 0;
frameData.scaledHeight = 0;
frameData.quality = 80;
saved=true;
nvds_obj_enc_process (obj_ctx_handle, &frameData, surface, NULL, frame_meta);
}
}
}
nvds_obj_enc_finish (obj_ctx_handle);
//frame_number++;
return GST_PAD_PROBE_OK;
}
