在Docker内运行带摄像头的yolov5

0h4hbjxa  于 2023-02-21  发布在  Docker
关注(0)|答案(1)|浏览(331)

我试图用yolov5模型对Docker容器中Nvidia Jetson Nano的网络摄像头流进行推断。在我的Windows PC和Jetson上,我都得到了错误:

qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.10/site-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

Dockerfile看起来像这样:

FROM python:latest

WORKDIR /yolov5_aiss

COPY requirements.txt . 

RUN pip3 install -r requirements.txt

COPY ./app ./app
RUN apt-get update -y
RUN apt-get install -y ffmpeg libsm6 libxext6  -y
RUN apt install -y libxkbcommon-x11-0

CMD ["python", "./app/detect.py", "--weights","./app/weights/best.pt", "--source", "0"]
kqlmhetl

kqlmhetl1#

这就是解决办法。

pip uninstall opencv-python
pip install opencv-python-headless
    • 注**

无头模式不能使用detect.py--view-img标志

相关问题