I am using a Jetson Nano B01 board on a custom carrier board. When trying to use nvarguscamerasrc in a gstreamer pipeline that ends with appsink, a blank image gets saved with terminal output being Segmentation Fault [core dumped]. The python script should capture images until stopped with Ctrl-C. Both python and C++ scripts work on the Jetson Xavier AGX for reference. The gstreamer pipeline in the code also works from terminal can captures the correct image. Code below:
import cv2
cap = cv2.VideoCapture("nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), format=NV12, width=4056, height=3040, framerate=20/1 ! nvvidconv flip-method=0 !
videoconvert! video/x-raw, format=BGR ! appsink", cv2.CAP_GSTREAMER)
i = 0;
while(cap.isOpened()):
ret, frame = cap.read()
if ret == False:
break
cv2.imwrite('image'+str(i)+'.jpg',frame)
i+=1
cap.release()
cv2.destroyAllWindows()
Terminal output:
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 13000, max 660000000;
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 4056 x 3040 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;
GST_ARGUS: 3840 x 2160 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;
GST_ARGUS: 1280 x 720 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 4
Output Stream W = 4056 H = 3040
seconds to Run = 0
Frame Rate = 22.000001
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0] global /home/nanosd/opencv/modules/videoio/src/cap_gstreamer.cpp (1081) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
^CTraceback (most recent call last):
File "test.py", line 9, in <module>
cv2.imwrite('image'+str(i)+'.jpg',frame)
KeyboardInterrupt
GST_ARGUS: Cleaning up
Segmentation fault (core dumped)
Also used the same pipeline in a C++ script and ran with gdb and verbose error messages are below:
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/nanosd/door_SLAM/camera_stuff/final_codes/FOV:250/stitch/src/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fae2a9db0 (LWP 9717)]
[New Thread 0x7fadaa8db0 (LWP 9718)]
[New Thread 0x7fad2a7db0 (LWP 9719)]
[New Thread 0x7facaa6db0 (LWP 9720)]
[New Thread 0x7faac9fdb0 (LWP 9721)]
[New Thread 0x7faa49edb0 (LWP 9722)]
[New Thread 0x7fa9c9ddb0 (LWP 9723)]
[New Thread 0x7fa949cdb0 (LWP 9725)]
GST_ARGUS: Creating output stream
[New Thread 0x7fa8c6bdb0 (LWP 9783)]
[New Thread 0x7fa3ffedb0 (LWP 9784)]
[New Thread 0x7fa37fddb0 (LWP 9785)]
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 13000, max 660000000;
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;
GST_ARGUS: 4056 x 3040 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;
GST_ARGUS: 3840 x 2160 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;
GST_ARGUS: 1280 x 720 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 4
Output Stream W = 4056 H = 3040
seconds to Run = 0
Frame Rate = 22.000001
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[New Thread 0x7fa1e58db0 (LWP 9788)]
[ WARN:0] global /home/nanosd/opencv/modules/videoio/src/cap_gstreamer.cpp (1081) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
frame:0
Resolution of the video: 4056 x 3040
capturing image.
done capturing.
GST_ARGUS: Cleaning up
[Thread 0x7fa37fddb0 (LWP 9785) exited]
[Thread 0x7fa8c6bdb0 (LWP 9783) exited]
Thread 11 "argus_thread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fa3ffedb0 (LWP 9784)]
0x0000007fb0790508 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvargus_socketclient.so
(gdb) c
Continuing.
[Thread 0x7fa1e58db0 (LWP 9788) exited]
[Thread 0x7fa3ffedb0 (LWP 9784) exited]
[Thread 0x7fa949cdb0 (LWP 9725) exited]
[Thread 0x7fa9c9ddb0 (LWP 9723) exited]
[Thread 0x7faa49edb0 (LWP 9722) exited]
[Thread 0x7faac9fdb0 (LWP 9721) exited]
[Thread 0x7facaa6db0 (LWP 9720) exited]
[Thread 0x7fad2a7db0 (LWP 9719) exited]
[Thread 0x7fadaa8db0 (LWP 9718) exited]
[Thread 0x7fae2a9db0 (LWP 9717) exited]
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb)
The program is not being run.
(gdb) q
I found a similar topic here:
with a solution of patching the gstnvarguscamerasrc.cpp file, but I was unable to find that file in the root directory, nor the L4T source code. Can anyone help?