Dokcer use opencv on windows11

Yes, it is the docker issue for windows system. There is a $DISPLAY parameter on linux, but I don’t know for windows.
Installing the opencv cost a long time, so I provide the python version to speed up the debug time.

using this command run the docker

docker run -it onnxruntime-test bash

Then run

python3 video.py

The below are the files

dockerfile (or any dockerfile image with opencv )

ARG OPENVINO_VERSION=2023.0.0

# Build stage
FROM openvino/ubuntu20_runtime:${OPENVINO_VERSION} AS base-build
ENV WORKDIR_PATH=/home/openvino
WORKDIR $WORKDIR_PATH
ENV DEBIAN_FRONTEND noninteractive
ENV CPU_CORE_NUM 4
USER root

Run the docker and pip install -r requirements.txt
requirements.txt

matplotlib>=3.3
numpy>=1.22.2
opencv-python>=4.1.1

video.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import cv2

#cap = cv2.VideoCapture(0)
cap = cv2.VideoCapture("chaplin.mp4")

if not cap.isOpened():
    print("Cannot open camera")
    exit()

#cv2.namedWindow("live", cv2.WINDOW_AUTOSIZE); 
while(True):

    ret, frame = cap.read()
    if not ret:
        print("Can't receive frame (stream end?). Exiting ...")
        break


    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


    cv2.imshow('live', frame)
    #cv2.imshow('live', gray)


    if cv2.waitKey(1) == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

error log

qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.8/dist-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

Aborted