Detected images are blurred even at 25FPS

Please provide complete information as applicable to your setup.

• GPU)
• v5
• 440.64.00

Thanks for supporting this community with Deepstream SDK , it really makes things smooth . Also thanks to contributors for making it available to others.

I am trying to process real time feed from RTSP ip camera at 25FPS , when I use gst-dsexample to save detected object into my disk , I tend to get blurred image most of the times. To my surprise when I play 25 FPS images are very sharp. Wanted to understand what could be wrong here.

Captured using gst-dsexample
2020-07-29T19:22:27_2_Person_386_960_284_482

Captured directly from camera
cam01

These are my source and sink settings if it helps :

[source1]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP
type=4
latency=500
uri=rtsp://admin:@192.168.1.12:554/mode=real&idc=1&ids=1
num-sources=1
#drop-frame-interval=2
camera-id=1
gpu-id=0
# (0): memtype_device   - Memory type Device
# (1): memtype_pinned   - Memory type Host Pinned
# (2): memtype_unified  - Memory type Unified
cudadec-memtype=0

[sink1]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File
type=0
sync=1
qos=0
source-id=1
gpu-id=0
nvbuf-memory-type=0

[streammux]
gpu-id=0
##Boolean property to inform muxer that sources are live
live-source=1
batch-size=8
##time out in usec, to wait after the first buffer is available
##to push the batch even if the complete batch is not formed
batched-push-timeout=40000
## Set muxer output width and height
width=1920
height=1080
##Enable to maintain aspect ratio wrt source, and allow black borders, works
##along with width, height properties
enable-padding=0
nvbuf-memory-type=0

Following is my camera source setting , camera_setting

Appreciate any pointers to solve this issue.

Did you try with sync = 0 in sink1?

Could be a couple of reasons for this.

Firstly - your dsexample config… it scales the image so check the config settings

Second - the default dsexample has an option to guassian blur the frame - do you have that turned on?

@ekimku yes its the same with sync =0 and sync =1

@jasonpgf2a , processing width and processing height is same as camera resolution, also my scale ratio in gstdsexample.cpp is 1 .

   dest_width = src_width;
   dest_height = src_height;

Transformation params:

   transform_params.transform_flag =
     NVBUFSURF_TRANSFORM_FILTER | NVBUFSURF_TRANSFORM_CROP_SRC |
       NVBUFSURF_TRANSFORM_CROP_DST;
   transform_params.transform_filter = NvBufSurfTransformInter_Default; 

Not sure if I have guassian blur turned off or on , where can I find that specific option ?

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

I’m not sure - maybe the detail is in here: https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_quick_start.html#

I just remember when I was toying with the dsexample code for my own purposes (motion detection) that it scales the frame when creating the cv::Mat and in some circumstances calls guassian blur.

Check the source for the detail - its only a small file. ;-)

Yes already checked that file cant find anything related to guassian blur , also scale is set to 1 so there is no scaling issue either. Let me go line by line and try to figure this out , thank you for your response

I’m looking on DS5.0dp - maybe the guassian blur is only in that version.

Yes , I will try to use DS5.0 code instead of old version and see if it works

This is how I am trying to save detected object :

  cv::Mat in_mat, out_mat;
  gint src_left = GST_ROUND_UP_2((unsigned int)crop_rect_params->left);
  gint src_top = GST_ROUND_UP_2((unsigned int)crop_rect_params->top);
  gint src_width = GST_ROUND_DOWN_2((unsigned int)crop_rect_params->width);
  gint src_height = GST_ROUND_DOWN_2((unsigned int)crop_rect_params->height);

  dest_width = src_width;
  dest_height = src_height;
in_mat =
      cv::Mat (dest_height, dest_width,
      CV_8UC4, dsexample->inter_buf->surfaceList[0].mappedAddr.addr[0],
      dsexample->inter_buf->surfaceList[0].pitch);

#if (CV_MAJOR_VERSION >= 4)
  cv::cvtColor (in_mat, out_mat, cv::COLOR_RGBA2BGR);
#else
  cv::cvtColor (in_mat, out_mat, CV_RGBA2BGR);
#endif
  out_mat = cv::Mat (cv::Size(dest_width, dest_height), CV_8UC3);

  cv::cvtColor (in_mat, out_mat, CV_RGBA2BGR);

Still unable to resolve , any pointers ?

Hopefully someone from nvidia can take a look as I’ve run out of ideas… Last thing would be to test your config with full_frame=1 and see what happens. When full-frame is 0 I thought it just cropped out the image inside the bounding box.

A few months back when DS5.0dp first came out I was creating a motion detection using dsexample as a base and when I dumped images to full they were full resolutions so I’m not sure whats wrong with your test.

Hopefully someone from nvidia can take a look for you…

yes valid point , may be I can try with full frame and crop data separately and see how it looks

Yeah I think what your doing at the moment is cropping out the bounding box and then blowing it up to 1920x1080.

I checked if that is the case , but its not , my detection boundary aspect ratio is maintained in final image as well

gint src_left = GST_ROUND_UP_2((unsigned int)crop_rect_params->left);
  gint src_top = GST_ROUND_UP_2((unsigned int)crop_rect_params->top);
  gint src_width = GST_ROUND_DOWN_2((unsigned int)crop_rect_params->width);
  gint src_height = GST_ROUND_DOWN_2((unsigned int)crop_rect_params->height);

  /* Maintain aspect ratio */
  double hdest = dsexample->processing_width * src_height / (double) src_width;
  double wdest = dsexample->processing_height * src_width / (double) src_height;
  guint dest_width, dest_height,top,left;
  dest_width = src_width;
  dest_height = src_height;

Turns out saving entire frame and then cropping is bad for run time and performance especially when you have 10 streams running in parallel , although I tried that one and still poor results

@kayccc any pointers on this ?

Is there anyone from Nvidia who can help me here?

@DaneLLL Any pointers?

Hi
There is a sample of saving to disk. FYR.

You can try to launch RTSP server through test-mp4. See if the issue is specific to your source. An example of executing test-mp4: