Jetson AGX Orin
GStreamer: 1.16.3
Jetpack: 5.0.2
CUDA Version: 11.4
Operating System + Version: Ubuntu 20.04.4 LT
TensorRT Version: 8.4.1.5-1+cuda11.4
Python Version: 3.8.2-0
I’m trying to display image with container
Here’s the command I do:
docker run --gpus all -it --name test -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --ipc=host –v /home/aaeon/test:/workspace lpr
After enter container:
python /workspace/readVideo.py
And the error message:
No protocol specified
Traceback (most recent call last):
File “/workspace/readVideo.py”, line 9, in
cv2.namedWindow(“Demo”, cv2.WINDOW_NORMAL)
cv2.error: OpenCV(4.5.3) /git/opencv-4.5.3/modules/highgui/src/window_gtk.cpp:635: error: (-2:Unspecified error) Can’t initialize GTK backend in function ‘cvInitSystem’
I’ve found a similar topic for my question, but it’s not work before running container
I have to execute “xhost +” every time before executing the python script in container
Here’s the python script
import cv2
rtsp_url = ‘rtsp://77.110.228.219/axis-media/media.amp’
cap = cv2.VideoCapture(rtsp_url)
cv2.namedWindow(“Demo”, cv2.WINDOW_NORMAL)
cv2.resizeWindow(“Demo”, 960, 540)
if not cap.isOpened():
print(“can not open RTSP stream!”)
exit()
while True:
ret, frame = cap.read()
if not ret:
break
cv2.imshow(‘Demo’, frame)
if cv2.waitKey(1) == ord(‘q’):
break
cap.release()
cv2.destroyAllWindows()
GUI backend for your opencv build seems to be GTK.
Is GTK installed in your container ?
If the opencv lib is the same out of docker and it works there, then try installing same GTK version into container if not yet done.
You may check what GUI backend and its version for an opencv build with function getBuildInformation().
For example, if using from python3:
python3 -c 'import cv2; print(cv2.getBuildInformation())' |& tee | grep -A 8 GUI
If the versions seems matching, it may be a GTK/X issue.
Can you run this simple GTK test from container or does it also fails to initialize ?
#!/usr/bin/env python
import gi
# You may adapt for your GTK version
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class GTK_Main:
def __init__(self):
window = Gtk.Window()
window.set_title("Test GTK")
window.set_default_size(100, 100)
window.connect("destroy", Gtk.main_quit, "WM destroy")
vbox = Gtk.VBox()
window.add(vbox)
hbox = Gtk.HBox()
vbox.pack_start(hbox, False, False, 0)
hbox.set_border_width(10)
self.button = Gtk.Button(label="Quit")
self.button.connect("clicked", self.exit)
hbox.pack_start(self.button, False, False, 0)
window.show_all()
def exit(self, w):
Gtk.main_quit()
GTK_Main()
Gtk.main()
If this also fails, you may post the error messages.
Or just checking X display from docker, does this work ?