Unable to display images using Open CV when using docker container

Environment:
Jetson AGX Xavier
GStreamer: 1.14.5
Jetpack: 4.6
CUDA Version: cuda_10.2_r440
Operating System + Version: Ubuntu 18.04.6 LT
TensorRT Version: 8.0.1-1+cuda10.2
Python Version: 3.6.9

Subject: Unable to display images using Open CV (cv2.imshow) when using docker container
Docker container: dustynv/jetson-inference:r32.6.1

From docker container we are getting below error message to display images using opencv libraries:
‘’’
No protocol specified
Unable to init server: Could not connect: Connection refused
Traceback (most recent call last):
File “test.py”, line 3, in
cv2.imshow(‘Camera Capture’, img)
cv2.error: OpenCV(4.5.0) /opt/opencv/modules/highgui/src/window_gtk.cpp:624: error: (-2:Unspecified error) Can’t initialize GTK backend in function ‘cvInitSystem’
‘’’

Please help us to resolve this issue…

Hi,

Please try to run xhost + before launching the container.

For example:

$ export DISPLAY=:0
$ xhost +
$ sudo docker run -it --rm --runtime nvidia --network host ...
root@nvidia-desktop:/# export DISPLAY=:0
root@nvidia-desktop:/# python3 my_script.py

Thanks.

Thank you for your suggestion it works when we run xhost + before launching the container.

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