![](/img/trans.png)
[英]qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb"
[英]qt.qpa.xcb: could not connect to display when using yolov4-custom-functions
我正在使用https://github.com/theAIGuysCode/yolov4-custom-functions這個存儲庫。 我想在網絡攝像頭上運行時裁剪和保存圖片。 但是當我運行以下代碼時:
python detect_video.py --weights ./checkpoints/yolov4-416 --size 416 --model yolov4 --video ./data/video/bobinmi.mp4 --output ./detections/results.avi --crop
我只能檢測到視頻的第一幀。 然后它給出錯誤而不檢測。 我應該怎么辦?
我正在使用 CUDA 10.1、Python 3.7 和 Tensorflow 2.3。 CPU 和 GPU 工作環境中的錯誤相同。
錯誤信息是:
FPS: 1.50
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.7/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.
Fatal Python error: Aborted
Current thread 0x00007fbeed09b780 (most recent call first):
File "detect_video.py", line 165 in main
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 254 in _run_main
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 308 in run
File "detect_video.py", line 178 in <module>
該錯誤消息僅在 Colab 中的第 165 行引起,即使用以下指令:
cv2.namedWindow("result", cv2.WINDOW_AUTOSIZE)
根據文檔,此 function 用於創建 window。 原因是 Colab 沒有屏幕,某些 cv2 函數需要屏幕才能執行操作。 創建 windows 絕對是其中之一。
要修復 Colab 中的錯誤應該足以安裝虛擬屏幕。 代碼(來自此堆棧答案):
!apt-get install -y xvfb # Install X Virtual Frame Buffer
import os
os.system('Xvfb :1 -screen 0 1600x1200x16 &') # create virtual display with size 1600x1200 and 16 bit color. Color can be changed to 24 or 8
os.environ['DISPLAY']=':1.0' # tell X clients to use our virtual DISPLAY :1.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.