I am using docker for the first time. I am using this image opencvcourses/opencv-docker. I try to run a scrip with openCV, but first i am going to explain how i run a simple code with print and numpy
I have my script (ej.py) on my ubuntu local directory: /home/noemi/Escritorio/contenedores/cont1/ej.py
import numpy as np
print('Esto es una prueba ok')
print(np.pi)
I run docker with the next command
docker run -it -v /home/noemi/Escritorio/contenedores/cont1:/home opencvcourses/opencv-docker
And, my script works! I obtain this
Esto es una prueba ok
3.141592653589793
But when I add to my script (ej.py) openCV code
import cv2
import numpy as np
img1 = np.zeros((6,8,1),np.uint8)
cv2.imshow('imagen-zeros',img1)
cv2.waitKey(0)
cv2.destroyAllWindows()
and try with the same command
docker run -it -v /home/noemi/Escritorio/contenedores/cont1:/home opencvcourses/opencv-docker
appear this error
Traceback (most recent call last):
File "ej.py", line 6, in <module>
cv2.imshow('imagen-zeros',img1)
cv2.error: OpenCV(4.5.1) /home/opencv/modules/highgui/src/window_gtk.cpp:624: error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem'
Please, I don't know what happened