Images getting blurry, Encoding frames/objects to Jpeg Image

Deepstream 6.4, dGPU

My pipeline looks like
uridecodebin -> streammux -> pgie -> tracker -> sgie_1 -> sgie_2 -> nvvidconv -> osd -> sink

I’m getting video stream from RTSP or a local file.
Im using following models.
PGIE :- CenterFace Model
SGIE_1 :- Nvidias Facial Landmarks Model
SGIE_2 :- Face Recognition model

I referred to the deepstream-image-meta-test sample application to learn how to encode the Frames and objects into JPEG image and attach them as metadata. Im doing that.

This is how my probe function looks, which is attached on the src pad of pgie.

GstPadProbeReturn
pgie_src_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info, gpointer ctx)
{
	GstBuffer *buf = (GstBuffer *)info->data;
	GstMapInfo inmap = GST_MAP_INFO_INIT;
	if (!gst_buffer_map(buf, &inmap, GST_MAP_READ))
	{
		GST_ERROR("input buffer mapinfo failed");
		return GST_PAD_PROBE_DROP;
	}
	NvBufSurface *ip_surf = (NvBufSurface *)inmap.data;
	gst_buffer_unmap(buf, &inmap);

	NvDsObjectMeta *obj_meta = NULL;
	guint frame_count = 0;
	guint num_objects = 0;
	NvDsMetaList *l_frame = NULL;
	NvDsMetaList *l_obj = NULL;
	NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);

	for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
		 l_frame = l_frame->next)
	{
		NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);
		frame_count = frame_meta->frame_num;
		num_objects = frame_meta->num_obj_meta;
		/* For demonstration purposes, we will encode the first 10 frames. */
		if (EncodeFrame) 
        #ignore this (EncodeFrame) variable for this forum post, assume :-> if(1){}
		{
			NvDsObjEncUsrArgs frameData = {0};
			/* Preset */
			frameData.isFrame = 1;
			/* To be set by user */
			frameData.saveImg = 0;
			frameData.attachUsrMeta = attach_user_meta;
			/* Set if Image scaling Required */
			frameData.scaleImg = FALSE;
			frameData.scaledWidth = 0;
			frameData.scaledHeight = 0;
			/* Quality */
			frameData.quality = 100;
			/* Main Function Call */
			nvds_obj_enc_process((NvDsObjEncCtxHandle)ctx, &frameData, ip_surf, NULL, frame_meta);
		}
	}
	nvds_obj_enc_finish((NvDsObjEncCtxHandle)ctx);
	return GST_PAD_PROBE_OK;
}

and this is how I’m attaching the probe function.

 GstPad *pgie_src_pad = nullptr;
  pgie_src_pad = gst_element_get_static_pad(pgie, "src");
  NvDsObjEncCtxHandle obj_ctx_handle = nvds_obj_enc_create_context(0);
  if (!obj_ctx_handle)
  {
    g_print("Unable to create context\n");
    return -1;
  }
  if (!pgie_src_pad)
    g_print("Unable to get src pad\n");
  else
    gst_pad_add_probe(pgie_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
                      pgie_src_pad_buffer_probe, (gpointer)obj_ctx_handle, nullptr);
  gst_object_unref(pgie_src_pad);

Questions :->
[0] is this correct way of encoding the Frames/Objects ?
[1] The image quality that I’m getting is not good. Most of the times it is not clear.
I cross checked with the stream that I got from the camera and frames encoded by DeepStream, there was a difference in quality(In terms of Clarity, Blur, Sharpness). I’m unsure what is causing this. Is there any way to solve this?
[2] Which quality image goes downstream ? the one that I get from the camera or (kinda) one that I’m getting from DeepStream after encoding it and saving it ?
[3] Also, I realized that, Using this functionality of encoding images, makes my pipeline slower. I have seen posts on this forum regarding that but since those were tagged with older versions, I thought with DS6.4 this issue would not be there.

  1. Yes. It’s the correct way of encoding the Frames/Objects.
  2. The one that you get from the camera.

About the quality of the image, could you give a specific example?

the image that im getting from camera is more clear
the encoded image from pipeline, is pixelated

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

Is the resolution the same between the image from camera and the encoded image from pipeline? Could you attach the 2 images?

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