Jetson ORIN NX devices hardware decoding error

etpack 5.1.2
Python 3.8
OpenCV-python 4.5.5.64 installed via pip3

I have deployed a Python program on the system. This program is a UI interface created using PyQt5. When I click a button on this UI, it launches yolov5’s detect.py. I modified this script to pull an H.264 format RTSP stream from a wireless camera. The real-time video results from detect.py are displayed on the UI interface. Everything works fine when using the opencv-python package downloaded via pip3.

However, after uninstalling the original opencv-python package and attempting to compile OpenCV 4.5.5:

cd opencv-4.5.5/build
export PY_NAME=$(python3.8 -c 'from sys import version_info as v; print("python%d.%d" % v[:2])')
export PY_NUMPY_DIR=$(python3.8 -c 'import os.path, numpy.core; print(os.path.dirname(numpy.core.__file__))')

sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local  -D PYTHON_DEFAULT_EXECUTABLE=$(which python3.8) -D PYTHON3_EXECUTABLE=$(which python3.8) -D WITH_GSTREAMER=ON -D PYTHON3_INCLUDE_DIR=/usr/include/$PY_NAME -D PYTHON3_INCLUDE_DIR2=/usr/include/aarch64-linux-gnu/$PY_NAME -D PYTHON3_LIBRARY=/usr/lib/aarch64-linux-gnu/lib$PY_NAME.so -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include -D BUILD_DOCS=OFF -D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D WITH_FFMPEG=ON -D BUILD_PERF_TESTS=OFF ..

sudo make -j8
sudo make install

After successfully compiling OpenCV, when I run the program and click the same button, the following error occurs:

(python3:503510): GLib-GObject-WARNING **: 13:37:53.638: cannot register existing type 'GdkDisplayManager'

(python3:503510): GLib-CRITICAL **: 13:37:53.638: g_once_init_leave: assertion 'result != 0' failed

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.638: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

(python3:503510): GLib-GObject-WARNING **: 13:37:53.638: invalid (NULL) pointer instance

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.638: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(python3:503510): GLib-GObject-WARNING **: 13:37:53.638: invalid (NULL) pointer instance

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.638: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(python3:503510): GLib-GObject-WARNING **: 13:37:53.641: cannot register existing type 'GdkDisplay'

(python3:503510): GLib-CRITICAL **: 13:37:53.641: g_once_init_leave: assertion 'result != 0' failed

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.641: g_type_register_static: assertion 'parent_type > 0' failed

(python3:503510): GLib-CRITICAL **: 13:37:53.641: g_once_init_leave: assertion 'result != 0' failed

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.641: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

Hi,
You may try this sample and see if it works:
Increasing play speed decoding from mp4 file - #9 by DaneLLL

If the environment is good, it shall be run successfully.

Hi,I try this file:

import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("filesrc location=test.mkv ! matroskademux ! h264parse ! nvv4l2decoder enable-max-performance=1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink sync=0 ")
    if cap.isOpened():
        count = 0;
        while True:
            ret_val, img = cap.read();
            if not ret_val:
                break;
            count = count + 1
            if count % 150 == 0:
                print("decoded frames:", count)
    else:
        print("rtsp open failed")

    cap.release()

if __name__ == '__main__':
    read_cam()

It can not work:

Opening in BLOCKING MODE 

(python3:17020): GStreamer-CRITICAL **: 11:41:13.922: 
Trying to dispose element capsfilter1, 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.


(python3:17020): GStreamer-CRITICAL **: 11:41:13.922: 
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.


(python3:17020): GStreamer-CRITICAL **: 11:41:13.922: 
Trying to dispose element nvvconv0, 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.


(python3:17020): GStreamer-CRITICAL **: 11:41:13.922: 
Trying to dispose element h264parse0, 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.


(python3:17020): GStreamer-CRITICAL **: 11:41:13.922: 
Trying to dispose element filesrc0, 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.


(python3:17020): GStreamer-CRITICAL **: 11:41:13.922: 
Trying to dispose element pipeline0, but it is in READY 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.

[ WARN:0@0.151] global /home/orange/Desktop/opencv-4.5.5/modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline

(python3:17020): GStreamer-CRITICAL **: 11:41:13.923: 
Trying to dispose element videoconvert0, 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.

[ WARN:0@0.151] global /home/orange/Desktop/opencv-4.5.5/modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

(python3:17020): GStreamer-CRITICAL **: 11:41:13.923: 
Trying to dispose element appsink0, but it is in READY 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.


(python3:17020): GStreamer-CRITICAL **: 11:41:13.923: 
Trying to dispose element nvv4l2decoder0, 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.

rtsp open failed

(python3:17020): GStreamer-CRITICAL **: 11:41:13.939: gst_element_post_message: assertion 'GST_IS_ELEMENT (element)' failed

Hi,
You can check if the pipeline is valid by running gst-launch-1.0 command with fakesink:

$ gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! h264parse ! nvv4l2decoder enable-max-performance=1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! fakesink

If your video file is different please modify the pipeline accordingly.

Hi,it can not work:
gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! h264parse ! nvv4l2decoder enable-max-performance=1 ! nvvidconv ! video/x-raw, format=\(string\)BGRx ! videoconvert ! video/x-raw,format=BGR ! fakesink

Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Delayed linking failed.
Additional debug info:
./grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
failed delayed linking some pad of GstMatroskaDemux named matroskademux0 to some pad of GstH264Parse named h264parse0
ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Internal data stream error.
Additional debug info:
matroska-demux.c(5732): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

but this file can be work :

import cv2
import time

pipeline = "rtspsrc location=rtsp://192.168.0.131:554/test latency=0 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! videorate ! video/x-raw,width=2560,height=1440,framerate=25/1, format=(string)BGRx! videoconvert ! appsink sync=false"

capture = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

#c=0
while True:
    res, frame = capture.read()

    cv2.imshow("Video", frame)
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        break
capture.release()
cv2.destroyAllWindows()

But the error related to GLib-GObject that I mentioned earlier still persists.

Hi,
If the error is only shown with your self-build OpenCV, it may be something wrong in building the package. You may try to use this script to build 4.5.4 and see if it works:

JEP/script/install_opencv4.6.0_Jetson.sh at master · AastaNV/JEP · GitHub

We don’t observe the issue by running it to manually install Open CV on developer kit(Orin NX module + Orin Nano carrier board). Please give it a try.

Hello, I used a shell script from the website to install OpenCV, but my JetPack 5.1.2 failed to install v4l2ucp, so I skipped it. After the installation was complete, the test program still reported error:

(python3:503510): GLib-GObject-WARNING **: 13:37:53.638: cannot register existing type 'GdkDisplayManager'

(python3:503510): GLib-CRITICAL **: 13:37:53.638: g_once_init_leave: assertion 'result != 0' failed

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.638: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

(python3:503510): GLib-GObject-WARNING **: 13:37:53.638: invalid (NULL) pointer instance

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.638: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(python3:503510): GLib-GObject-WARNING **: 13:37:53.638: invalid (NULL) pointer instance

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.638: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(python3:503510): GLib-GObject-WARNING **: 13:37:53.641: cannot register existing type 'GdkDisplay'

(python3:503510): GLib-CRITICAL **: 13:37:53.641: g_once_init_leave: assertion 'result != 0' failed

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.641: g_type_register_static: assertion 'parent_type > 0' failed

(python3:503510): GLib-CRITICAL **: 13:37:53.641: g_once_init_leave: assertion 'result != 0' failed

(python3:503510): GLib-GObject-CRITICAL **: 13:37:53.641: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

but I can successfully run the program when using the SSH protocol communication feature of MobaXterm. MobaXterm’s SSH protocol supports X11 forwarding, so I can see the results of the program’s execution.

I tried to use printenv to check the difference between two environments:

The result in the local environment:

SHELL=/bin/bash
SESSION_MANAGER=local/mn-desktop:@/tmp/.ICE-unix/2692,unix/mn-desktop:/tmp/.ICE-unix/2692
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
XDG_MENU_PREFIX=gnome-
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
JETSON_CUDA_ARCH_BIN=8.7
LC_ADDRESS=zh_CN.UTF-8
GNOME_SHELL_SESSION_MODE=ubuntu
LC_NAME=zh_CN.UTF-8
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
XMODIFIERS=@im=ibus
DESKTOP_SESSION=ubuntu
LC_MONETARY=zh_CN.UTF-8
SSH_AGENT_PID=2537
GTK_MODULES=gail:atk-bridge
PWD=/home/mn
XDG_SESSION_DESKTOP=ubuntu
LOGNAME=mn
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
JETSON_MODULE=NVIDIA Jetson Orin NX (16GB ram)
XAUTHORITY=/run/user/1000/gdm/Xauthority
WINDOWPATH=2
HOME=/home/mn
USERNAME=mn
IM_CONFIG_PHASE=1
LC_PAPER=zh_CN.UTF-8
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XDG_CURRENT_DESKTOP=ubuntu:GNOME
VTE_VERSION=6003
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/817b8183_2bd8_4e9f_a760_931788f4a143
JETSON_L4T=35.4.1
INVOCATION_ID=57a2e032b134439584a4fe7c2f16e01c
MANAGERPID=1768
JETSON_CODENAME=P3768
JETSON_MODEL=NVIDIA Orin NX Developer Kit
JETSON_SERIAL_NUMBER=1424023009389
LESSCLOSE=/usr/bin/lesspipe %s %s
JETSON_SOC=tegra23x
XDG_SESSION_CLASS=user
PYTHONPATH=/usr/local/lib/python3.8/site-packages/:/usr/local/lib/python3.8/site-packages:
TERM=xterm-256color
LC_IDENTIFICATION=zh_CN.UTF-8
LESSOPEN=| /usr/bin/lesspipe %s
USER=mn
GNOME_TERMINAL_SERVICE=:1.81
DISPLAY=:0
SHLVL=1
LC_TELEPHONE=zh_CN.UTF-8
QT_IM_MODULE=ibus
LC_MEASUREMENT=zh_CN.UTF-8
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/cuda-11.4/lib64:
XDG_RUNTIME_DIR=/run/user/1000
LC_TIME=zh_CN.UTF-8
JOURNAL_STREAM=8:60007
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
PATH=/usr/local/cuda-11.4/bin:/home/mn/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
GDMSESSION=ubuntu
JETSON_P_NUMBER=p3767-0000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
JETSON_JETPACK=5.1.2
LC_NUMERIC=zh_CN.UTF-8
_=/usr/bin/printenv

The result in the SSH remote environment:

SHELL=/bin/bash
JETSON_CUDA_ARCH_BIN=8.7
LC_ADDRESS=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_MONETARY=zh_CN.UTF-8
PWD=/home/mn/Desktop
LOGNAME=mn
XDG_SESSION_TYPE=tty
JETSON_MODULE=NVIDIA Jetson Orin NX (16GB ram)
MOTD_SHOWN=pam
HOME=/home/mn
LC_PAPER=zh_CN.UTF-8
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
JETSON_L4T=35.4.1
SSH_CONNECTION=192.168.0.106 4209 192.168.0.120 22
JETSON_CODENAME=P3768
JETSON_MODEL=NVIDIA Orin NX Developer Kit
JETSON_SERIAL_NUMBER=1424023009389
LESSCLOSE=/usr/bin/lesspipe %s %s
JETSON_SOC=tegra23x
XDG_SESSION_CLASS=user
PYTHONPATH=/usr/local/lib/python3.8/site-packages/:/usr/local/lib/python3.8/site-packages:
LC_IDENTIFICATION=zh_CN.UTF-8
TERM=xterm
LESSOPEN=| /usr/bin/lesspipe %s
USER=mn
DISPLAY=localhost:10.0
SHLVL=1
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
XDG_SESSION_ID=3
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/cuda-11.4/lib64:
XDG_RUNTIME_DIR=/run/user/1000
SSH_CLIENT=192.168.0.106 4209 22
LC_TIME=zh_CN.UTF-8
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
PATH=/home/mn/.local/bin:/usr/local/cuda-11.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
JETSON_P_NUMBER=p3767-0000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
SSH_TTY=/dev/pts/1
JETSON_JETPACK=5.1.2
LC_NUMERIC=zh_CN.UTF-8
OLDPWD=/home/mn
_=/usr/bin/printenv```

Hi,
It looks like it fails in rendering the frames. Please remove the function call and see if it works:

cv2.imshow("Video", frame)

Hi,it works, thanks for help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.