Use CSI Camera in Deepstream

Basic information.

• Hardware Platform (Jetson AGX Xavier)
• DeepStream Version 4.0
• JetPack Version 4.3
• TensorRT Version 6
• Issue Type( bugs)

I have tried the deepstream-app with video file source and it run successfully. But when I want to use CSI camera instead of the video source as the input of the pipeline, the issue happened. When I do not set osd_sink_pad_probe the pipeline will work well. But when I add this probe, the segmentation fault (core dumped) happened.
So, what’s the problem I have met?deepstream_test1_app.c (11.0 KB)

We do not have CSI camera to repro your issue, can you follow this to get the backtrace when the segfault happened?

Thank you. I have tried the gdb to backtrace the segfault happened.

(gdb) run
Starting program: /home/jia/work/deepstream_c_apps/sources/apps/apps-sample/deepstream-test1-camera/deepstream-test1-app 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/".
[New Thread 0x7fb4ec51f0 (LWP 9949)]
[New Thread 0x7fb46c41f0 (LWP 9950)]
[New Thread 0x7fb3ec31f0 (LWP 9951)]
[New Thread 0x7fb36c21f0 (LWP 9952)]
[New Thread 0x7fb2ec11f0 (LWP 9953)]
[New Thread 0x7fb26c01f0 (LWP 9954)]
Now playing: (null)

Using winsys: x11 
[New Thread 0x7fa2a7c1f0 (LWP 9955)]
[New Thread 0x7fa21601f0 (LWP 9956)]
Creating LL OSD context new
0:00:04.014745094  9945   0x5555d8d950 INFO                 nvinfer gstnvinfer.cpp:519:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]:initialize(): Trying to create engine from model files
[New Thread 0x7fa0bf41f0 (LWP 9959)]
0:00:44.883386902  9945   0x5555d8d950 INFO                 nvinfer gstnvinfer.cpp:519:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]:generateTRTModel(): Storing the serialized cuda engine to file at /opt/nvidia/deepstream/deepstream-4.0/samples/models/Primary_Detector/resnet10.caffemodel_b1_int8.engine
[New Thread 0x7f6393a1f0 (LWP 9961)]
[New Thread 0x7f61c601f0 (LWP 9962)]
[New Thread 0x7f6145f1f0 (LWP 9963)]
[New Thread 0x7f60c5e1f0 (LWP 9964)]
[New Thread 0x7f4ffff1f0 (LWP 9965)]
Creating LL OSD context new
[New Thread 0x7f4f7fe1f0 (LWP 9967)]
[New Thread 0x7f4effd1f0 (LWP 9968)]
GST_ARGUS: Creating output stream
[New Thread 0x7f4e7fc1f0 (LWP 10032)]
[New Thread 0x7f4dffb1f0 (LWP 10033)]
[New Thread 0x7f4d7fa1f0 (LWP 10034)]
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3864 x 2180 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 30.000000; Exposure Range min 7000, max 166725000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 0 
   Output Stream W = 3864 H = 2180 
   seconds to Run    = 0 
   Frame Rate = 59.999999 
GST_ARGUS: PowerService: requested_clock_Hz=27216000
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.

Thread 11 "deepstream-test" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f6393a1f0 (LWP 9961)]
strlen () at ../sysdeps/aarch64/strlen.S:94
94      ../sysdeps/aarch64/strlen.S: No such file or directory.

So can you help me find which file I lost and how can I do to fix it. Thanks.

Can you type bt and get the backtrace?

(gdb) bt
#0  0x0000007fb7c08450 in strlen () at ../sysdeps/aarch64/strlen.S:94
#1  0x0000007fb7d7e4f8 in g_strdup () at /usr/lib/aarch64-linux-gnu/

Did you make change to osd_sink_pad_probe when segfault issue happened?

No. When I do not use osd_sink_pad_probe the segfault will disappeared.

So it should be related with this probe function. please add debug option in deepstream-app makefile, and debug further.

Your issue is similar with Segmentation Fault in Docker Deepstream Tracker - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums, please try to see if that helps?

I have tried debug and find in probe function txt_params->text_bg_clr.alpha = 1.0; is the keypoint. Now I can run without it.