I'm trying to run a Python GUI app from a docker container, but when I'm trying to display on fullscreen, nothing shows up. If I'm not calling cv2.setWindowProperty("frame", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
, the windows appears on screen normaly.
This is the Dockerfile used :
# syntax = docker/dockerfile:1.0-experimental
FROM arm64v8/debian:latest
RUN apt update && apt install -y \
ca-certificates \
gnupg \
curl
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" \
| tee /etc/apt/sources.list.d/coral-edgetpu.list \
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt update && apt install -y \
python3 \
python3-pip \
python3-opencv \
python3-pycoral \
zlib1g-dev \
libjpeg-dev
RUN pip3 install \
v4l2 \
screeninfo \
pillo
And this is the script:
import cv2
import screeninfo
# Capture video from webcam
vid_capture = cv2.VideoCapture(1)
while True:
# Capture each frame of webcam video
screen = screeninfo.get_monitors()[0]
cv2.namedWindow("frame", cv2.WND_PROP_FULLSCREEN)
cv2.moveWindow("frame", screen.x - 1, screen.y - 1)
cv2.setWindowProperty("frame", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
ret, frame = vid_capture.read()
cv2.imshow("frame", frame)
# Close and break the loop after pressing "x" key
if cv2.waitKey(1) & 0xFF == ord("x"):
break
# close the already opened camera
vid_capture.release()
# close the window and de-allocate any associated memory usage
cv2.destroyAllWindows()
I'm using the following docker run
command:
docker run -d --rm \
--device /dev/apex_0:/dev/apex_0 \
--device /dev/video1:/dev/video1 \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix \
guiapp bash
Before running the container, I'm making sure that the environment is configured with these:
export DISPLAY=:0
xhost +
I can't think of anything that may cause this strange behaviour.
EDIT: after further investigation, I found out that I face the same problem when logged in as root
.