CSI-camera is not work on Jetson Xavier nx

Hi,
I’m trying to connect imx219-83 stereo camera with Jetson Xavier nx and using gstreamer to capture webcam.
Here’s the code I used to capture webcam

cv::VideoCapture cap_driver(pipeline, cv::CAP_GSTREAMER);

And the pipeline is

nvarguscamerasrc sensor_mode=2 sensor-id=1 ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1280, format=(string)NV12, framerate=(fraction)10/1 ! nvvidconv flip-method=2 ! video/x-raw, width=(int)800, height=(int)600, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink

And when I’m using cap_driver.isOpened() to test if webcam captured success or not, but I receive following errors.

Assertion `cap_driver.isOpened()' failed.

I try to use GitHub - JetsonHacksNano/CSI-Camera: Simple example of using a CSI-Camera (like the Raspberry Pi Version 2 camera) with the NVIDIA Jetson Nano Developer Kit to test if webcam work fine or not, and it shows webcam work fine. So I’m not sure where the problem is, is there anyway I can print out error message more precisely?

Run the gst-launch-1.0 command to check if any validate message.

Also check if the driver loaded by v4l2-ctl --list-devices

Hi, I’m testing with both command
command gst-launch-1.0 shows error below

gst-launch-1.0 nvarguscamerasrc sensor_mode=2 sensor-id=1 ! video/x-raw, width=1920, height=1280, format=NV12, framerate=10/1 ! nvvidconv flip-method=2 ! video/x-raw, width=800, height=600, format=I420, appsink max-buffer=1 drop=true

(gst-launch-1.0:7217): GStreamer-CRITICAL **: 16:11:49.606: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
WARNING: erroneous pipeline: no element "video"

And command v4l2-ctl --list-devices show message below

vi-output, imx219 9-0010 (platform:15c10000.vi:0):
	/dev/video0

vi-output, imx219 10-0010 (platform:15c10000.vi:2):
	/dev/video1

So it means my drivers are loadad correctly but my pipeline has syntax errors?

Your command is incorrect try below.

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, format=(string)I420' ! appsink

I’m trying the correct command you suggested.
Here’s the result

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, format=(string)I420' ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

ARGUS_ERROR: Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute: 787 Frame Rate specified is greater than supported
GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 0 
   Output Stream W = 3264 H = 2464 
   seconds to Run    = 0 
   Frame Rate = 21.000000 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
ARGUS_ERROR: Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute: 1007 InvalidState.
GST_ARGUS: Cleaning up
nvbuf_utils: dmabuf_fd -1 mapped entry NOT found
nvbuf_utils: Can not get HW buffer from FD... Exiting...
ERROR: from element /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0: CANCELLED
Additional debug info:
Argus Error Status
Execution ended after 0:00:00.555465521
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Caught SIGSEGV
#0  0x0000007fa13ca7f4 in __pthread_clockjoin_ex (threadid=548067918304, thread_return=0x0, clockid=0, abstime=<optimized out>, block=<optimized out>)
#1  0x0000007fa1488ab8 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x0000005594974d40 in  ()
Spinning.  Please run 'gdb gst-launch-1.0 6729' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

And I run the command ‘gdb gst-launch-1.0 6729’, I get the result 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 gst-launch-1.0...(no debugging symbols found)...done.
Attaching to program: /usr/bin/gst-launch-1.0, process 6729
[New LWP 6731]
[New LWP 6732]
[New LWP 6735]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
__pthread_clockjoin_ex (threadid=548067918304, thread_return=0x0, clockid=0, 
    abstime=<optimized out>, block=<optimized out>)
    at pthread_join_common.c:145
145	pthread_join_common.c: No such file or directory.

Did you run the command from remote control like ssh?
Please export DISPLAY=:0 first.

No, I run the command directly from local terminal on Nvidia Jetson Xavier nx.
I tried export DISPLAY=:0 first, but get the same result

$ export DISPLAY=:0
$ gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, format=(string)I420' ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

ARGUS_ERROR: Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute: 787 Frame Rate specified is greater than supported
GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 0 
   Output Stream W = 3264 H = 2464 
   seconds to Run    = 0 
   Frame Rate = 21.000000 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
ARGUS_ERROR: Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute: 1007 InvalidState.
GST_ARGUS: Cleaning up
nvbuf_utils: dmabuf_fd -1 mapped entry NOT found
nvbuf_utils: Can not get HW buffer from FD... Exiting...
ERROR: from element /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0: CANCELLED
Additional debug info:
Argus Error Status
Execution ended after 0:00:00.805915565
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Caught SIGSEGV
#0  0x0000007fac6eb7f4 in __pthread_clockjoin_ex (threadid=548255748576, thread_return=0x0, clockid=0, abstime=<optimized out>, block=<optimized out>)
#1  0x0000007fac7a9ab8 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x000000557cbd2d40 in  ()
Spinning.  Please run 'gdb gst-launch-1.0 8046' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

Wha’t your version.

cat /etc/nv_tegra_release

$ cat /etc/nv_tegra_release
# R32 (release), REVISION: 5.1, GCID: 27362550, BOARD: t186ref, EABI: aarch64, DATE: Wed May 19 18:16:00 UTC 2021

What’s the sensor frame rate. Add “framerate=10/1”

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, framerate=10/1, format=(string)I420' ! appsink```

The original pipeline is using frame rate 10/1

$ gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, framerate=10/1, format=(string)I420' ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

ARGUS_ERROR: Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute: 787 Frame Rate specified is greater than supported
GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 0 
   Output Stream W = 3264 H = 2464 
   seconds to Run    = 0 
   Frame Rate = 21.000000 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
ARGUS_ERROR: Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute: 1007 InvalidState.
GST_ARGUS: Cleaning up
nvbuf_utils: dmabuf_fd -1 mapped entry NOT found
nvbuf_utils: Can not get HW buffer from FD... Exiting...
ERROR: from element /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0: CANCELLED
Additional debug info:
Argus Error Status
Execution ended after 0:00:00.542137672
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Caught SIGSEGV
#0  0x0000007f790c77f4 in __pthread_clockjoin_ex (threadid=547393671648, thread_return=0x0, clockid=0, abstime=<optimized out>, block=<optimized out>)
#1  0x0000007f79185ab8 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x00000055826bc080 in  ()
Spinning.  Please run 'gdb gst-launch-1.0 7495' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

Sorry the frame rate should be here.

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280, framerate=10/1' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, format=(string)I420' ! appsink
``

The result is below

$ gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=1920,height=1280, framerate=10/1' ! nvvidconv flip-method=2 ! 'video/x-raw, width=800, height=600, format=(string)I420' ! appsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 1 
   Output Stream W = 3264 H = 1848 
   seconds to Run    = 0 
   Frame Rate = 28.000001 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.

Looks like running without problem. If you have HDMI display you can try xvimagesink to check the preview.

Thanks for helping, I will try xvimagesink to check the preview.