I have a Jetson NX 16GB dev kit with Jetpack 5.0.1 as OS. As a base image for my docker container I use nvcr.io/nvidia/l4t-pytorch:r34.1.1-pth1.12-py3. My opencv version inside the container is 4.5.5.
Before I start my container I run “xhost +” in the terminal. I run my container with the following flags:
docker run -it --rm \ -v "$HOME/.Xauthority:/root/.Xauthority:rw" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ --runtime=nvidia \ --net=host \ -e LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1 \ -e DISPLAY=$DISPLAY \ --privileged \ my_image:latest
The --privileged flag only worked after I changed the l4t.csv according to this post: Error running privileged L4T containers with the NVidia Runtime on JetPack 5.0 Developer Preview - #10 by AastaLLL. However, as soon as I want to use cv2.imshow() an error occurs. So I want to execute the following code:
import cv2 image = cv2.imread("/img/snapshot.png") cv2.imshow("img", image)
and this is the output (I used QT_DEBUG_PLUGINS=1 beforehand):
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ... qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Aborted (core dumped)
Nevertheless it is strange that if I use a tool like shotwell:
apt install shotwell shotwell /img/snapshot.png
the image opens without any problem. I can also open a camerastream with arv-viewer. So my question is: How can I open a .png file with cv2.imshow inside my container? Is there a problem with cv2, have I missed a library or is this a bug from another type?
Thanks in advance for your help.