using with Xavier Error: by jkjung-atv - tegra_cam.py with Xavier

Hi all,

I’ve moved and mounted the on-board camera from TX2 DevKit to Xavier DevKit and it works perfectly, for example with jetson-inference demo.

Link: https://jkjung-avt.github.io/tx2-camera-with-python/

I’m trying to use jkjung-avt tutorials and I’m trying to use his GStreamer tegra_cam.py but the cam is not working (/dev/video0) with the following error:

nvidia@JetsonXavier:/media/nvidia/SD32/Installazioni/tegra-cam$ python3 tegra-cam.py 
Called with args:
Namespace(image_height=360, image_width=720, rtsp_latency=200, rtsp_uri=None, use_rtsp=False, use_usb=False, video_dev=0)
OpenCV version: 3.4.3
^C
(python3:18349): GStreamer-CRITICAL **: 12:05:45.920: 
Trying to dispose element capsfilter0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
...
Trying to dispose element nvvconv0, but it is in PAUSED instead of the NULL state.
...
Trying to dispose element pipeline0, but it is in READY instead of the NULL state.

Anybody could help me please? The same tutorial with tegra_cam.py was well working on the TX2 DevKit, so I do not see why it could not work with Xavier DevKit.
Both with original JetPack 4.1 OpenCV 3.3.1 and with the new installed OpenCV 3.4.3 the same error is raised with Xavier.

Thanks in advance

Hi,

Have you built OpenCV with GStreamer support?

Please noticed that Xavier is using volta GPU architecture.
If you use this script, please modify the flag into ’ CUDA_ARCH_BIN=“7.2” '.

cmake -D WITH_CUDA=ON -D <b>CUDA_ARCH_BIN="7.2"</b> -D CUDA_ARCH_PTX="" -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

Thanks.

Thanks a lot for your reply, AastaLLL,

my script:

sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
        -D WITH_CUDA=ON -D CUDA_ARCH_BIN=“7.2” -D CUDA_ARCH_PTX="" \
        -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON \
        -D ENABLE_NEON=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF \
        -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF \
        -D WITH_QT=ON -D WITH_OPENGL=ON ..

I’ve missed

-D WITH_GSTREAMER=ON

I’ re-try to compile and install my OpenCV 3.4.3.

My best to all

Hi!
even recompiling opncv-3.4.3 and reinstalling it with GSTREAMER=ON I’m am still not able to use on board camera.

I’m still investigating on this issue, on board camera is working only with demo jetson-inference.

I’m able to use USB camera with:

and with:

only changing:

- return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
+ return cv2.VideoCapture(1)

I’m suspecting something wrong with GStream.

Anybody could try to investigate with me on this issue?

Very thanks for sharing Xavier-experiences

Hi, maybe you should try nvarguscamerasrc instead for the onboard cam. I had the same issue after migrating over to Xavier from TX2 but able to fix it.

You may also check that the version used by python is the one you’ve installed.
You may check cv version in python, and further check its build options:

import cv2
print(cv2.__version__)
print(cv2.getBuildInformation())

In build info, you would check for gstreamer support (this comes from a R28.2 on TX2, versions may differ):

<b>  Video I/O:</b>
    DC1394:                      YES (ver 2.2.4)
    FFMPEG:                      YES
      avcodec:                   YES (ver 56.60.100)
      avformat:                  YES (ver 56.40.101)
      avutil:                    YES (ver 54.31.100)
      swscale:                   YES (ver 3.1.101)
      avresample:                NO
[b]    GStreamer:                   
      base:                      YES (ver 1.8.3)
      video:                     YES (ver 1.8.3)
      app:                       YES (ver 1.8.3)
      riff:                      YES (ver 1.8.3)
      pbutils:                   YES (ver 1.8.3)
[/b]    libv4l/libv4l2:              NO
    v4l/v4l2:                    linux/videodev2.h

Here are mine, still GStreamer not working.

OpenCV 3.4.3 as expected:

>>> print(cv2.__version__)
3.4.3

GStreamer YES as expected:

Video I/O:
    DC1394:                      YES (ver 2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (ver 57.107.100)
      avformat:                  YES (ver 57.83.100)
      avutil:                    YES (ver 55.78.100)
      swscale:                   YES (ver 4.8.100)
      avresample:                NO
    GStreamer:                   
      base:                      YES (ver 1.14.1)
      video:                     YES (ver 1.14.1)
      app:                       YES (ver 1.14.1)
      riff:                      YES (ver 1.14.1)
      pbutils:                   YES (ver 1.14.1)
    libv4l/libv4l2:              1.14.2 / 1.14.2
    v4l/v4l2:                    linux/videodev2.h

Seems ok for gstreamer support in opencv from python.
Probably @javax66615 'solution will help further.

Hi,

Could you check the sample in this comment?
[url]https://devtalk.nvidia.com/default/topic/1042892/jetson-agx-xavier/nvarguscamerasrc-opencv-solved-/post/5290833/#5290833[/url]

Thanks.

Hi, thanks, I published the solution I found and tested here

[url]https://devtalk.nvidia.com/default/topic/1043623/jetson-agx-xavier/on-board-cam/[/url]

Best regards