In gst-dsexample, NVBuffer's pitch is wrong

Hello.

I have been using the plugin template provided in dsexample to perform some opencv algorithms within the deepstream SDK with Jetson TX1. However the images I get within the plugin have suddenly became corrupted when working at some resolutions. I have traced the issue to the function get_converted_mat, where I have found the value of buf_params.pitch[0] is always zero (at in_mat = cv::Mat (dsexample->processing_height, dsexample->processing_width,CV_8UC4, mapped_ptr,buf_params.pitch[0]);). As consequence opencv does not know the padding of the buffer and if there is any padding opencv cannot properly retrieve the image. To discard that the error was on my modifications to the plugin, I compiled the original source, adding just one line to print the value of buf_params.pitch[0]. And I found that the pitch is also zero there.

Has anyone else came across this issue or has any suggestions on how to fix it?
Thanks

Can you provide your code for reproducing and further debugging if possile?

Thank you for your reply amycao. I reproduced the error on the code as provided in “DeepStream_SDK_on_Jetson_1.5_pre-release” I just added a printf in line 378. Here is the code:

https://drive.google.com/file/d/1IV0toWuzPudqwx0gUWSIbUqsJ7_MrAV5/view?usp=sharing

On further tests I noticed sometimes the pitch is reported as 127 which can’t be right either because the processing-width is larger than that. I added the following to the default “PGIE-FP16-CarType-CarMake-CarColor.txt”:

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

HI Fernando
I try to use your code to reproduce this issue, i use same dsexample config as you, and use the video from the ds package, run to end, and i can not reproduce your issue, can you specify more details how to repro the issue, how about the repro rate? does it happen always or the repro rate is low?

just paste one output clip

buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
**PERF: 36.49 (36.90)
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680
buf_params.pitch[0]=7680

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

It is happening every single run since the first time it appeared. Here is a sample of the output

buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127

**PERF: FPS 0 (Avg)
**PERF: 34.00 (34.00)
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127
buf_params.pitch[0]=127

My guess is it could be something beyond the code, as it used to work properly before in my TX1 at any resolution. Are there any packages related to nvbuffer that could have become corrupted? Maybe I could try reinstalling them.

Hi Fernando,

Need your detail step to reproduce, pitch is 256 byte aligned in theory.
127/0 is obvious wrong.

Thanks
wayne zhu