【问题标题】:Could not load the Qt platform plugin (while dockerizing the application)无法加载 Qt 平台插件(在 dockerizing 应用程序时)
【发布时间】:2021-08-10 11:24:42
【问题描述】:

我使用 opencv 和迁移学习模型 (resnetSSD) 构建了一个人脸检测应用程序。 应用程序的输出:视频将打开,模型将能够识别人脸。

应用程序在我的本地系统中完美运行.. 也可以构建 docker,但是在运行 docker 容器时出现以下错误:

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.6/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.

请建议我如何解决这个问题??

【问题讨论】:

  • 没有 docker 我也有同样的问题——但我不记得我做了什么来解决它。我不确定我是重新安装了cv2,还是安装了更新的PyQt5,或者帮助安装了PyQt6

标签: python docker qt opencv face-recognition


【解决方案1】:

要显示 Docker 容器内的图像,您应该像下面这样运行它:

docker run -it \
   -e DISPLAY=$DISPLAY \                # <--- here
   -v /tmp/.X11-unix:/tmp/.X11-unix \   # <--- Here
# everyting else

确保cv2 正确安装在 docker 映像中后,您可能希望运行

xhost +local:root

在主机上(假设是本地实验)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 2015-06-06
    • 2016-11-16
    • 2016-01-08
    相关资源
    最近更新 更多